AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Year plan · Computing

Variables, input and casting

Week 2 · Unit 7.1: Block it out · 3 lessons
Answers are for parents and teachers.
1
Explain what a variable is. Then say what happens to the old value when a variable gets a new value.
2
What does this program show?
Python
1apples = 3
2print("Basket:", apples, "apples")
3apples = 5
4print("Basket:", apples, "apples")
3
Write a program that asks ‘Name of your favourite song?’ and ‘How many minutes long is it?’, and then shows both answers in one line.
4
The user types 20. Find the two mistakes and write the corrected program.
Python
1age = input("Age of the tree? ")
2print("In five years:", age + 5)
Output
TypeError: can only concatenate str (not "int") to str
5
Choose the best data type (string, integer or real) for each: the name of a village, the number of seats on a bus, the weight of a parcel in kilograms (2.35), a house number written as 12B.