Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

QUESTION IS IN PYTHON PLEASE ANSWER IN PYTHON Question 1 : 3 points Create a text file named sports.txt and enter the sports listed below,

QUESTION IS IN PYTHON PLEASE ANSWER IN PYTHONimage text in transcribed

Question 1 : 3 points Create a text file named sports.txt and enter the sports listed below, one word per line. Enter and execute the program. Be sure the saved program is in the same folder as the text file FYI: In Python, you can access data from a text file as well as from the keyboard. You can create a text file in any text editing tool. You should only have one data item per line in the file. If you use Notepad (Windows) or TextEdit (Mac) make sure your settings are for Plain Text not Rich Text You can also use Thonny to save a .txt file. Python Program 1 def main (): sportsList open ('sports . txt') spsportsList .read () print(sp) 4 o main 7main sports.txt 1 basketball 2 baseball 3 football 4 volleyball 5 tennis 6 golf 7soccer 8 hockey 9swimming 10 rowing (a) (1 point) What does the program do? (b) (1 point) In the Line 2 of code, what does the string argument for the function open represent? (c) (1 point) Replace the call to the function read () with the function readline(). Execute the program again. Explain the difference between the two functions: read() and readline()

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

Students also viewed these Databases questions

Question

What has been your desire for leadership in CVS Health?

Answered: 1 week ago