Question: Rewrite / finish the analyze function to print out: - the average number of comments across all posts - the average score of posts across

Rewrite/finish the analyze function to print out:
- the average number of comments across all posts
- the average score of posts across all posts
- what the highest score is and the title for that post
- what the lowest score is and the title for that post
- what the most commented post is with its title and number of comments
--> Note: The data contains posts and comments, and you must separate those for accurate results.
And following is a starter program that you can run using Python on your own computer. Note that you will need to have the CSV file in the same directory as your python script in order for this to work correctly.
import csv
def analyze(entries):
print(f'first entry: {entries[0]}')
with open("reddit_vm.csv","r", encoding='UTF-8', errors="ignore") as input:
entries =[(e['id'], int(e['score']), int(e['comms_num']), e['title']) for e in csv.DictReader(input)]
avgScore = analyze(entries)
Here is an example run of the program (these are not the correct data values):
$ python main.py
Average score: 8.4
Average comments per post: 7.64
Highest score: 1031, title: Some post title
Lowest score: -12, title: Some post title
Most comements: 463, title: Some post title
 Rewrite/finish the analyze function to print out: - the average number

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!