Question: Data Source: http://www.pewinternet.org/dataset/jan-3-10-2018-core-trends-survey/ Note: This is the only question for this star and only the age range will change. Save and test your code in

Data Source: http://www.pewinternet.org/dataset/jan-3-10-2018-core-trends-survey/ Note: This is the only question for this star and only the age range will change. Save and test your code in Codenvy so you can paste it for credit in case you don't get it right on the first try. You are analyzing the results of a survey about the Internet and you want to know how often a specific age range of people use the Internet. You will be given a file containing a subset of the source data in the format "eminuse,intmob,intfreq,age" where all values are well-formed integers. This header will be the first line of the file and the column values are:

eminuse

Do you use the Internet? 1: yes 2: no

intmob

Do you use the Internet on mobile? 1: yes 2: no

intfreq

How often do you use the Internet? 1: Almost constantly 2: Several times a day 3: Once a day 4: Several times a week 5: Once a week or less Empty String: Responder answered 2 to eminuse and intmob

age

Responders age in years

Note: The file has been filtered. If you download the original file you will have to add additional logic to handle responses of 8: Don't know, 9: Refused to answer, etc. Write a function named "internet_histogram" that takes no parameters and does not return a value. There will be a file named "survey.csv" in the testing environment containing survey results as described above (the file has a header line which much be addressed by your code). Write a new file named "histogram.csv" containing 2 columns representing "internet_use,frequency" and no header line that will contain a histogram of the results of responders ages 18 to 25 including the endpoint ages. Your file will have exactly 6 lines with internet_use values of 1-5 corresponding to the intfreq results and 6 for responders who answered 2 to eminuse. Read the survey results file and track how many responders in this age range answered with each of these 6 options and write these counts to your "histogram.csv" file in order of internet_use starting with 1. Example histogram.csv: 1,5 2,7 3,0 4,1 5,2 6,4

following is my code...

import csv def internet_histogram(): with open("histogram.csv","w",newline = "")as f: writer = csv.writer(f) for i in range(1,7): with open("survey.csv",newline = "") as file: reader = csv.reader(file) next(file) total = 0 for line in reader: if (25 <= int(line[3])<= 34): if i ==6: total = total+1 if line[2] == str(i): total = total + 1 writer.writerow([i,total])

But I'm not getting the right result, someone please help me with the correct code. I'm so confused

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!