logo Use CA10RAM to get 10%* Discount.
Order Nowlogo
(5/5)

You have been provided a file cereal.csv which contains Comma-Separated Values (CSV) on the nutritional data of 77 brands of cereal.

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

1. You have been provided a file cereal.csv which contains Comma-Separated Values (CSV) on the nutritional data of 77 brands of cereal. The first line in the file is a header line, which describes what each column corresponds to for the remaining lines.

Using this cereal data, write a program called cereal.py to answer a few interesting questions. To start, write a function makeCerealList () which reads cereal.csv into a list of lists, where each sublist corresponds to one row in the file. Since this is a CSV file, you'll want to use .split(',') on each input line to convert a row with commas into a list of strings with no commas. The function should return the list of lists (data).

Since there is only one filename, you don't need to prompt the use to enter it. You can simply hard-code "cereal.csv" into the main () of your program. Because the provided tests operate on a different file, the makeCerealList () function should take a filename as input. It should return a list of lists, something like this:

[['100% Bran'

'Nabisco', 'Cold', 70, 4, 1, 130, 10.0], ['100% Natural Bran' 'Quaker Oats', 'Cold', 120, 3, 5, 15, 2.0], ['All-Bran', 'Kelloggs', 'Cold', 70, 4, 1, 260, 9.0],

Note: some data has been converted into int and some data has been converted into float.

2. What cereal has the most calories? Write a function most_calories (data) which returns a string; the cereal name that has the most calories.

3. What cereal has the highest protein-to-fat ratio (i.e., protein / fat)? Write a function highest_protein_fat_ratio (data) which returns a string; the cereal name that has the highest protein-to-fat ratio.

4. How many types of 'Hot' cereal are there? Write a function

number_of_hot_cereal (data) which returns an int; the number of cereals with type 'Hot.' For this function, you must use recursion.

5. What cereals are produced by the manufacturer 'Kelloggs'? Write a function

cereals_by_kelloggs (data) which returns a list of strings; the names of the cereals with manufacturer "Kelloggs."

There are included tests with this assignment to help guide you which operate on a smaller CSV file: tiny.cereal.tsv To pass the tests your program should have five functions (as described in points 1-5 above).

You should not hard-code the correct answers into any of the functions. Also, for this assignment you should not use the built-in functions min (), max (), find () or other such "search" functions.

 

(5/5)
Attachments:

Expert's Answer

395 Times Downloaded

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

395 Times Downloaded

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Um e HaniScience

818 Answers

Hire Me
expert
Muhammad Ali HaiderFinance

858 Answers

Hire Me
expert
Husnain SaeedComputer science

974 Answers

Hire Me
expert
Atharva PatilComputer science

694 Answers

Hire Me

Get Free Quote!

310 Experts Online