Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 PYTHONimage text in transcribed

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

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

Genetic Databases

Authors: Martin J. Bishop

1st Edition

ISBN: 0121016250, 978-0121016258

More Books

Students also viewed these Databases questions