Python - Section 7 Practice Tasks
Task One
Example solution:
Create a program with three different subroutines (procedures).
One subroutine asks the user their name and prints a response.
The second asks for their age and prints a response.
The third asks for their favourite colour and prints a response.
Remember to write subroutines before the main program.
Task Two
Create a program that asks a user to input the length of a side in a square.
Write a function that takes this value and returns it to be printed.
Example solution:
Task Three
Example solution:
Create a program that takes 3 inputs from the user – a name, a villain and a place.
Write a function that outputs a story using the user’s answers.
Task Four
Create a calculator program that uses four different subroutines (add, subtract, multiply and divide).
In the main program ask the user to make a choice of which operator to use and then to enter two numbers. Keep looping until the user types stop.
​
Use the 'Using Subroutines as a Menu' section in the 7b to help you.
Example solution: