EXERCISE TOPIC▼
- Access exercises (91)
- C# exercises (79)
- Excel exercises (278)
- Power Apps exercises (13)
- Power Automate exercises (18)
- Power BI exercises (139)
- Power Platform exercises (157)
- Python exercises (28)
- Report Builder exercises (141)
- SQL exercises (198)
- SSAS exercises (51)
- SSIS exercises (46)
- SSRS exercises (99)
- VBA exercises (85)
- Visual Basic exercises (46)
PYTHON EXERCISES▼
PYTHON EXERCISES▼
Python | Files and folders exercise | Read in a text file containing Muppet data, and print it out
This exercise is provided to allow potential course delegates to choose the correct Wise Owl Microsoft training course, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.
Software ==> | Python (28 exercises) |
Version ==> | Latest version |
Topic ==> | Files and folders (3 exercises) |
Level ==> | Average difficulty |
Subject ==> | Python training |
You need a minimum screen resolution of about 700 pixels width to see our exercises. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.
The text file in the folder above contains a list of Muppets:

The file stores the animal type and colour of each Muppet.
Write a program which does the following to get the results shown below:
Step | Hint |
---|---|
Opens the file | Use with open(file_path,"r") as file_name |
Reads in the lines | Use read() to get the entire contents, then apply splitlines() to get a list of lines |
For each line, gets the details | Use split(",") to get a list of the details |
Prints out the results for each | You could use muppet, animal, colour = muppet_list to unpack the list into distinct variables |
You don't have to use the hints - there are many ways to skin a python!
Your program should produce this output:

The final list of Muppets your program should print.
When everything is working, close down your program!