Python Practical 14
Python Practical 14
Q1 Open a blank file in your text editor and write a few lines summarizing what you’ve
learned about Python so far. Start each line with the phrase In Python you can.... Save the
file as learning_python.txt in the same directory as your exercises from this chapter. Write a
program that reads the file and prints what you wrote three times. Print the contents once by
reading in the entire file, once by looping over the file object, and once by storing the lines in
a list and then working with them outside the with block.
Q2 Write a while loop that prompts users for their name. When they enter their name, print a
greeting to the screen and add a line recording their visit in a file called guest_book.txt. Make
sure each entry appears on a new line in the file.
guest_book.txt
Q3 Write a while loop that asks people why they like programming. Each time someone
enters a reason, add their reason to a file that stores all the responses.
programming_poll.txt