Python - Section 10 Practice Tasks

Task One

Create a file in Python called DaysOfTheWeek.txt.

Write the days of the week into the file in a single print line but put each day on a new line.

Check the file to see if it has worked.

Example solution:

Task Two

Create a file called Colours.txt.

Use a for loop to ask the user to enter 8 different colours.

Write each colour onto the same line, with a space between the colours.

Close the file and open it again in read mode and print it.

Example solution:

Task Three

Create a file named "Holiday.txt".

Ask the user to enter the family name, destination and and number of passengers.

Print each family's details on their own line.

Bonus: Edit this program to add a search feature to look for the family name.

Example solution:

Task Four

Use the holiday file from task three above. You are going to change the destination.

Ask the user to enter a family name and then a new destination.

Update the destination with the new value. 

 

Check the file to ensure the destination has been updated successfully.

Use section 10c to help you with this task.

Example solution:

© CSNewbs 2020