Your first task is to write a program in the file rating_stats.py which loads the file "data/full- data.txt" and, using

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Your first task is to write a program in the file rating_stats.py which loads the file "data/full- data.txt" and, using

Post by answerhappygod »

Your First Task Is To Write A Program In The File Rating Stats Py Which Loads The File Data Full Data Txt And Using 1
Your First Task Is To Write A Program In The File Rating Stats Py Which Loads The File Data Full Data Txt And Using 1 (136.04 KiB) Viewed 14 times
Please create a python code that can follow the attached image
guidelines to produce that result.
Recall that to calculate a percentage of reviews which are high
for a given gender you should divide the count of the number of
reviews which are both for that
gender and high by the count of
the number of reviews for that gender. Then, to turn this decimal
into a percent, first multiply by 100 and then convert to an
integer using the round() function.
The round() function is a handy Python function that will
round a floating point value to the nearest integer, allowing us to
produce the nice output format we want.
Without getting into the math too deeply we note that given the
amount of data we have access to, any number you calculate is
likely to deviate by 1 to 2 percentage points.
Note that the user has specified the path to the data file
including the directory data, since the
file full-data.txt is in the data subdirectory
of the project folder.
Also note that you can use the next() function of a
file object (as in next(file) if you just want to read a
single line from a file. This might be helpful to read the first
(header) line of the file before then going into a loop to read all
the lines of actual data in the file.
Your first task is to write a program in the file rating_stats.py which loads the file "data/full- data.txt" and, using all the data in that file, calculates and prints two numbers: 1. The percent of reviews for women which are rated high (the rating is greater than 3.5) 2. The percent of reviews for men which are rated high (the rating is greater than 3.5) When you run your program it should look like this: > py rating_stats.py Which data file would you like to load? data/full-data.txt 57% of reviews for women in the dataset are high. 58% of reviews for men in the dataset are high.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply