Read our blogs, tips and tutorials
Try our exercises or test your skills
Watch our tutorial videos or shorts
Take a self-paced course
Read our recent newsletters
License our courseware
Book expert consultancy
Buy our publications
Get help in using our site
523 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owl trainers only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Search our website
We also send out useful tips in a monthly email newsletter ...
Software ==> | Python (34 exercises) |
Topic ==> | Basic coding (3 exercises) |
Level ==> | Harder than average |
Subject ==> | Python training |
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.
This exercise asks you to write a program which displays your Hogwarts house colours given your input house name. Here's what a typical output should look like when you run the program:
Ravenclaw: the forgotten Harry Potter house?
First create a new program file called Sorting Hat.py, and set a variable to hold the house name typed in by a user.
To make it easier to test the value of your variable add .lower() to the end of it (this will convert whatever the user types in into lower case).
Before the next part of the exercise you'll need to know the Hogwarts house colours, which are:
House | Colours |
---|---|
Gryffindor | Scarlet and yellow (of course) |
Hufflepuff | Yellow and black |
Ravenclaw | Blue and bronze |
Slytherin | Green and silver (hissss ... !) |
Write an if ... elif ... else block which sets the value of another variable to the correct house colours (if the house typed in by your user doesn't exactly match any of the ones listed above, your program should set your colours to Not known).
Use the else clause of your if condition to return this message if a user types in an unknown house name.
Remember that you can use \n within a text string to throw a carriage return to get the new lines shown in our example.
Test that your program works by trying a few different house names, then save and close it.
You can find other training resources for the subject of this exercise here:
Kingsmoor House
Railway Street
GLOSSOP
SK13 2AA
Landmark Offices
99 Bishopsgate
LONDON
EC2M 3XD
Holiday Inn
25 Aytoun Street
MANCHESTER
M1 3AE
© Wise Owl Business Solutions Ltd 2025. All Rights Reserved.