Question: Load data from the data file ps3_chicken_data.txt Data is formatted in pairs of x,y on each line, where x is the name of the chicken

Load data from the data file ps3_chicken_data.txt

Data is formatted in pairs of x,y on each line, where x is the name of the chicken and y is indicates the weight of how much the chicken eats. (e.g. Chuck,12) All unique.

Helpful functions: str.split, open, file.readline, file.close

Read the contents of the given file. Assumes the file contents contain data in the form of comma-separated chicken name, weight pairs, and return a dictionary containing cow names as keys and corresponding weights as values.

Parameters:

filename - the name of the data file as a string

Returns:

a dictionary of chicken name (string), weight (int) pairs

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!