Quiz: First programs
Eight questions on values, variables, text, calculating, lists and your own functions in Python.
What does print("3" + "4") print?
Both values are in quotation marks and are therefore text. With text, +
joins the two together; nothing is calculated.
Someone types the number 19 at age = input("Age? "). What type does age have?
input always returns a string, even if only digits were typed. To
calculate with it, you convert it with int(...).
What do 17 // 5 and 17 % 5 return?
17 divided by 5 is 3 with remainder 2. // returns the whole-number part,
% the remainder.
Which of these can be the name of a variable in Python? (several are right)
Names consist of letters, digits and underscores and do not start with a
digit. A hyphen would be a minus sign, and class is a reserved word in
Python.
What does print(colors[1]) print if colors = ["red", "green", "blue"]?
The index starts at 0: colors[0] is "red", colors[1] is "green".
You reach the last element with colors[-1].
What does this program print?
numbers = [3, 8, 1]
numbers.append(5)
print(len(numbers), max(numbers), sorted(numbers)[0])append adds the 5 at the end, so the list then has four elements. The
largest is still the 8, and sorted(numbers)[0] is the smallest element,
the 1. The list numbers itself stays unsorted.
What value does result have at the end?
def double(number):
print(number * 2)
result = double(4)double only prints the 8 but returns nothing, because a return is
missing. A function without return returns None.
A program stops with NameError: name 'totl' is not defined. What most likely happened?
A NameError means that Python does not know a name. Usually it is a typo
like here, where total was probably meant, or the variable only gets a
value further down.
Download with answers: CSV Anki
Details
- Level
- Beginner
- Modules
- Digitization and Programming
- In learning paths
- Python for beginners
- Code
4381- Updated
- 1 November 2026
- Status
- published