top of page
top

Python - Section 7 Practice Tasks

noun-blocks-2032952-FFFFFF.png

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.

py105.PNG

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:

py106.PNG

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.

py107.png

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:

py93.png
bottom of page