0% found this document useful (0 votes)
4 views

Lesson 2 - Raw Input and Variables_Workbook

The document provides instructions for a Python programming lesson that involves user input and variable assignment. It includes tasks for creating programs that prompt users for their name and favorite films, as well as generating a Computing name based on user responses. Additionally, it addresses common syntax errors and encourages students to practice coding in SCRIPT mode.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Lesson 2 - Raw Input and Variables_Workbook

The document provides instructions for a Python programming lesson that involves user input and variable assignment. It includes tasks for creating programs that prompt users for their name and favorite films, as well as generating a Computing name based on user responses. Additionally, it addresses common syntax errors and encourages students to practice coding in SCRIPT mode.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Lesson 2

Including YOU and


variables

Python Programming
input() Task Explained

 What does the red box do?


It shows the text for the user.

 What happens in the green box?


The computer records the user’s answer as my_name.

 How does blue box work?


The computer uses the input that user gave to say something.
Extension Task
Mini Task
print("Please type your name in")
my_name = input ()
print("Nice to meet you ", my_name)
print("So ", my_name, " what is your favourite food?")
favourite_food = input ()
print("Ah, your favourite food is " , favourite_food)

QUESTIONS
1. Write down the name of a variable 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. Steve is writing his first program below. It won’t run properly. Can you spot
the Syntax error?

Print(‘Hello World’)
Questions

1. Write down the name of a variable used in the above program.


favourite_food, my_name
2. How many variables are used in the above program?
2
3. What kind of character/symbol is used to assign values to a variable?
input ()
4. Write down an example of assignment.

5. Steve is writing his first program below. It won’t run properly. Can you
spot the Syntax error?
He forgot to add the plus sign before and after the variables in the
code.
Today’s Task
Do this program in SCRIPT mode

Task: 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…

Hello [my_name], your top 5 favourite films are as follows:


1.[favourite_film1]
2.[favourite_film2]
3.[favourite_film3]
4.[favourite_film4]
5.[favourite_film5]

Here is an example of how it might look when finished ...


Hello Graham, your top 5 favourite films are as follows:
1.The Dark Knight
2.Joker
3.Lock Stock and Two Smoking Barrels
4.Ratatouille
5.Star Wars: Return of the Jedi
Task: 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
Today’s Task
run, the computer should output the following…

Hello [my_name], your top 5 favourite films are as follows:


1.[favourite_film1]
2.[favourite_film2]
3.[favourite_film3]
4.[favourite_film4]
5.[favourite_film5]
Paste your code below: Paste the results below:
Task 2
Do this program in SCRIPT mode
(i.e. go to FILE, NEW WINDOW…then press F5 to run)
Task: Create a program that asks the user three random questions and then gives them
their Computer Science classroom name based on their responses. For example,

What is your name? [name]


What is your favourite colour? [colour]
What is your favourite meal? [meal]
What is your favourite type of animal? [animal]

Well [name], your Computing name is ‘[colour] + [animal] + [meal]’

Here is an example of how it might look when finished ...


Well Stacey, your Computing name is BluePizzaMonkey

At the moment our Computing name doesn’t show spaces between the
results, how could you edit it to show spaces so that ‘BluePizzaMonkey’
becomes ‘Blue Pizza Monkey’?
Task: Create a program that asks the user three random questions and then gives them
their Computer Science classroom name based on their responses. For example,

What is your name? [name] Task 2


What is your favourite colour? [colour]
What is your favourite meal? [meal]
What is your favourite type of animal? [animal]

Well [name], your Computing name is ‘[colour] + [animal] + [meal]’

Paste your code below: Paste the results below:


At the moment our Computing name doesn’t show spaces between the
results, how could you edit it to show spaces so that ‘BluePizzaMonkey’
becomes ‘Blue Pizza Monkey’?
Task 2
Paste your code below: Paste the results below:

You might also like