Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. 2. 1 #write a function called reader that reads in a . cs1301 2 #file described in the previous problem. The function should

1. image text in transcribed

2.

image text in transcribed

1 #write a function called "reader" that reads in a " . cs1301" 2 #file described in the previous problem. The function should 3 #return a list of tuples representing the lines in the file like so: 5 #[(line-1-number, line-1-assignment-name, line-1-grade, line-2-grade, line-1-total , line-2-total , line-1-weight), line-2-weight)] 6 #(line-2-number, line-2-assignment-name, 8 #All items should be of type int except for the name (string) 9 #and the weight (float). You can assume the file will be in the 10 #proper format -- in a real program, you would use your code 11 #from the previous problem to check for formatting before 12 #trying to call the function below. 13 # 14 #Hint: Although you could use readlines() to read in all 15 #the lines at once, they would all be strings, not a list. 16 #You still need to go line-by-line and convert each string 17 #to a list. 18 19 20 #write your function here! 21 23 24 #Below are some lines of code that will test your function. 25 #You can change the value of the variable (s) to test your 26 #function with different inputs. 27 # 28 #If your function works correctly, this will originally 29 #print: 30 #1(1, 'assignment-1 ', 85, 100, 0.25), (2, 'test-1', 90, 100, 0.25), (3, 'exam-1 ', 95, 100, 0.5)] 31 print (reader( "sample.cs1301"))

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Object Databases The Essentials

Authors: Mary E. S. Loomis

1st Edition

020156341X, 978-0201563412

More Books

Students also viewed these Databases questions

Question

Question How are VEBA assets allocated when a plan terminates?

Answered: 1 week ago

Question

What are the objectives of Human resource planning ?

Answered: 1 week ago

Question

Explain the process of Human Resource Planning.

Answered: 1 week ago

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago