Answered step by step
Verified Expert Solution
Question
00
1 Approved Answer
please do in python Part IV: Assembling a Course Roster (20 points) In this part you will write a function that opens a file containing
please do in python Part IV: Assembling a Course Roster (20 points) In this part you will write a function that opens a file containing a list of students enrolled in courses and extract some data from the file. Each line of the file (after the first line) contains the name of a student, followed by the student's ID number, followed by a course code, followed by the number of credits for the course. These four quantities are separated by commas. The first line always contains the string Name, StudentID, CourseCode, Credits' Complete the function get.roster ) that takes the following arguments, in this order 1. filename: The name of a file that the function will read data from. You may assume that the file is always validly formatted. 2. course: A string representing a course code we are interested in. The function reads each line of the file filename and returns the list of ID numbers of students enrolled in the designated course. You may assume that each line of data in the file will always follow the following format: Student's Name, Student's ID #, Course Code, # of Credits). Note that ALL values in the file are treated as strings, even values we would normally treat as numerical. Below is a portion of a sample input file Name, StudentID, CourseCode, Credits Ariel,110071434, CSE101,3 Aldo, 110071435, CSE220,3 Julio,110071432,CSE220, 3 Aldo, 110071435, CSE114,4 Natalie, 110071433,CSE214,3 Ariel, 110071434, CSE219,4 Destiny,110071436, CSE214,3 Note: When reading each line, make sure to use the strip) function to get rid of any newlines and/or spaces before or after each line
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started