Question: Define a function read _ data that accepts a single argument corresponding to the filename, and returns a list of lists. You can find an

Define a function read_data that accepts a single argument corresponding to the
filename, and returns a list of lists.
You can find an example file to work within the Brightspace and the startercode
section of the Vocareum
Each line in the data file follows this format: [Name], num1, num2, num3....
Ben,-1,2.3,4.1,5.25,-4,0.2,0.55,1.1
Mary,2.1,1.4,-1.2,-1.5,1.0,2,3.1
Giulia,1.8,-2.2,-1.6,3
The function must return a list of lists where each sublist represents one line from the
file. All the numbers must be converted to float datatype in the returned value
Sample output:
>> print(read_data('sample_data.txt'))
[['Ben',-1.0,2.3,4.1,5.25,-4.0,0.2,0.55,1.1],['Mary',
2.1,1.4,-1.2,-1.5,1.0,2.0,3.1],['Giulia',1.8,-2.2,-
1.6,3.0]]

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!