Question: QUESTION IS IN PYTHON PLEASE ANSWER IN PYTHON Question 2: 10 points Enter and execute the following code. 1 sportsList open ('sports.txt') 2 for index
QUESTION IS IN PYTHON PLEASE ANSWER IN PYTHON
Question 2: 10 points Enter and execute the following code. 1 sportsList open ('sports.txt') 2 for index in range(1,11): 3sp sportsList.readline () 4 print (str (index)+". ",sp) (a) (1 point) How does the output from this program differ from the output of the program that used the read () function? (b) (1 point) What caused the difference? (c) (1 point) What is the subtle difference in the output if the following print statement replaced the one above? print(index,". "sp) (d) (1 point) Which is better? (e) (1 point) What does str(index) do in the program above? (f) (1 point) Why is the str function necessary? g) (1 point) What happens when you change the arguments in the range) function to 1,10? (h) (1 point) What happens when you change the arguments in the range() function to 0,30? i) (2 points) What do the results from 'd' and 'e' tell you about the arguments of the range () function when you are reading data from a file with a for loop
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
