Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In python Read text section 5.2 and review Section 3.4.3. Then answer the follow

ID: 3843140 • Letter: I

Question

In python

Read text section 5.2 and review Section 3.4.3. Then answer the following a. Write a single line of code that will ask the user for a filename and store the resulting filename into a variable named filename. b. Write a single line of code that will open the file specified by the user in part a and store the file reference in a variable named myFile. c. Write a for loop and related code that will print just the first 5 characters of each line of the file you opened in part b. d. Write a single line of code that will close the file, indicating the program is finished using it.

Explanation / Answer

1)fileName = input("enter file name")

2)myFile = open(filename,"r")

3) firstFive = myFile.readlines()
   for i in (firstFive):
       print(i[:5])

4)myfile.close()

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote