Programming with Python


Lesson Objectives

  • The need for variables in digital systems
  • To be able to explain what the use of variables
  • How to prompt the user for data and assign it to a variable.

Success Criteria

  • I understand what a variable is 
  • I know how to assign data to a variable 
  • I can use the input() function to captures user’s keyed in data.


  • String
  • Variable
  • Assign


  • input()
  • int()
  • print()


Discuss with the person next to you what is the difference between Interactive Mode (SHELL) and Script Mode
(hint: we use one of these to write larger and more complex programs).

When you are on interactive mode if you click File then New Window you will open below script mode window.

Task 2

Python Programming
Open your Python program from start button > all apps > Python 3.1 > select IDLE (Python GUI)
Write the below code in Script Mode, save it as and run it to see what happens.

Task 3

Explain in your book what do you think “name”, “year” and “age” do in above code?

Task 4

Complete below sentence in your book with your own words.

A variable is …

Task 5

Edit your program further by adding a new variable which will be assign to users favourite food.

You need to create a new variable called favourite_food by asking an input from a user to enter their favourite food
and you need to write a new line to output with their name, “Ah, your favourite food is” …

Save it and then Run it (F5)

Task 6 – QUESTIONS … you have 2 minutes!

Answer below questions in your book. Make sure you write Task 6 (you do not need to write the each question)

  1. Write down the name of a variables used in the above program
  2. How many variables are used in the above program
  3. What kind of character/symbol is used to assign values to a variable
  4. Write down an example of assignment
  5. Katie is writing her first program. It won’t run properly. Can you spot the Syntax error?

    Print(‘Hello World’)

Challenge Task


If you can, do all these programs in SCRIPT mode
(i.e. go to FILE, NEW WINDOW…then press F5 to run)

Create a program in python that prompts the user for their name AND the names of their top 5 favourite films. Each film should be assigned to a separate variable. When run, the computer should output the following…