Skip to content

Instantly share code, notes, and snippets.

View mayankdawar's full-sized avatar

Mayank Dawar mayankdawar

  • Ludhiana , Chandigarh , Mohali
View GitHub Profile
#include <iostream>
using namespace std;
struct Node
{
int data;
Node *next;
};
class link
{
public:
@mayankdawar
mayankdawar / avg_list.py
Created February 17, 2020 18:56
week_temps_f is a string with a list of fahrenheit temperatures separated by the , sign. Write code that uses the accumulation pattern to compute the average (sum divided by number of items) and assigns it to avg_temp. Do not hard code your answer (i.e., make your code compute both the sum or the number of items in week_temps_f) (You should use …
week_temps_f = "75.1,77.7,83.2,82.5,81.0,79.5,85.7"
temp_list = week_temps_f.split(',') #converting string into a list
lst=[float(i) for i in temp_list] #converting string values of list into float
avg_temp = sum(lst)/len(lst) #calculating average