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

Types, flags and fixed values

Week 9 · 1.5 Data in text-based programs · 3 lessons
Answers are for parents and teachers.
1
Choose the best data type for each: the number of goals, the price of a pen (0.75), the first letter of a name, a team’s motto, whether a light is on.
2
What does each line print? print(5 / 2), print("5" + "2"), print(int(4.9)), print(bool("")).
Python
1print(5 / 2)
2print("5" + "2")
3print(int(4.9))
4print(bool(""))
3
Write a Python program with a constant TAX = 2. Ask for a price and print the price plus the tax.
4
Write a line that stores in the flag raining whether the rain amount is more than 0, and an if line that uses it to print Take an umbrella.
5
Explain why the text "False" is not the same as the Boolean False, and what bool("False") gives.