Python Programming Introduction Quiz
Grade 6 · Technology · Quiz
Test your knowledge of Python basics including syntax, variables, and simple control structures.
Questions
What will print("Hello" + " " + "World") display?
- Hello World
- "Hello" "World"
- HelloWorld
- Error
Show answer
Answer: Hello World
The + operator concatenates strings in Python. 'Hello' + ' ' + 'World' produces 'Hello World'.
Which of the following is a valid Python variable name?
- 2myVar
- my-var
- my_var
- my var
Show answer
Answer: my_var
my_var is valid — it uses only letters and underscores. 2myVar starts with a number, my-var uses a hyphen, and my var has a space, all of which are invalid.
What data type is the value 3.14 in Python?
- integer
- string
- boolean
- float
Show answer
Answer: float
3.14 is a floating-point number (float) because it has a decimal point. Integers have no decimal portion.
What does the following code output? for i in range(3): print(i)
- 1 2 3
- 0 1 2
- 0 1 2 3
- 1 2
Show answer
Answer: 0 1 2
range(3) generates 0, 1, 2. Python's range starts at 0 by default and stops before the given number.
In Python, True and False must be capitalized.
Show answer
Answer: True
Python is case-sensitive. 'true' and 'false' are not recognized as booleans — only 'True' and 'False' with capital first letters are.
Which symbol is used to write a comment in Python?
- //
- /*
- #
- --
Show answer
Answer: #
The # symbol starts a comment in Python. // is used in JavaScript/C++, /* */ is for block comments in other languages, and -- is SQL.
What will the following code do? x = 5 if x > 3: print("big")
- Print nothing
- Print 'big'
- Print '5'
- Cause an error
Show answer
Answer: Print 'big'
Since x equals 5 and 5 > 3 is True, the indented block runs and prints 'big'.
The keyword used to define a function in Python is ______.
Show answer
Answer: def
The def keyword (short for define) is used to declare a function in Python, followed by the function name and parentheses.
Get a personalized course on Python Programming Introduction built around your child.