Which of the following for-loop correctly reads and prints records (one record per line) that are stored in the file which was successfully opened with the file stream fileIn? The file contains a list of student records. Each record is stored in two lines; student name and student age are stored in separate lines. A. for student in fileIn :name = fileIn.readline().rstrip()age = int(fileIn.readline())print(name, age) B. for student in fileIn :name = student.rstrip()age = int(fileIn.readline())print(name, age) C. for student in fileIn :name = student.rstrip()age = int(student)print(name, age) D. for student in fileIn :name = student age = int(fileIn.readline())print(name, age)
Which of the following for-loop correctly reads and prints records (one record per line) that are stored in the file which was successfully opened with the file stream fileIn?
The file contains a list of student records. Each record is stored in two lines; student name and student age are stored in separate lines.
A. for student in fileIn :
name = fileIn.readline().rstrip()
age = int(fileIn.readline())
print(name, age)
B. for student in fileIn :
name = student.rstrip()
age = int(fileIn.readline())
print(name, age)
C. for student in fileIn :
name = student.rstrip()
age = int(student)
print(name, age)
D. for student in fileIn :
name = student
age = int(fileIn.readline())
print(name, age)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images