Section A
Multiple Choice
40 marks
Question 1
What is the correct Python syntax to display
Hello, World!?Question 2
Which function is used to take input from the user in Python?
Question 3
What data type does
input() always return in Python 3?Question 4
What is the output of the following code?
print(3 + 4 * 2)
Question 5
Which keyword is used to define a function in Python?
Question 6
What will the following code output?
x = 10 y = 3 print(x % y)
Question 7
Which of the following correctly defines a function called
greet with one parameter name?Question 8
What does
// do in Python?Question 9
What is the output of this code?
def double(n): print(n * 2) double(5)
Question 10
To convert user input to an integer, which of the following is correct?
Question 11
What symbol starts a single-line comment in Python?
Question 12
What is the output of
print(2 ** 3)?Question 13
Which correctly calls a function
area passing the value 7?Question 14
What does this output?
a = 15 b = 4 print(a // b)
Question 15
What is a parameter in a Python function?
Question 16
What will
print(type(42)) output?Question 17
A student writes
name = input("Enter name: ") and types Alice. What is stored in name?Question 18
What is the output?
def square(x): print(x * x) square(4)
Question 19
Which statement correctly concatenates
name with "Hello, "?Question 20
What is the result of
print(10 / 4) in Python 3?Question 21
What is the output of the following?
def add_ten(n): print(n + 10) add_ten(5)
Question 22
Which of these stores a decimal number in Python?
Question 23
What will the following print?
print("5" + "3")
Question 24
Which line correctly converts the string
"3.14" into a float?Question 25
What is the output?
x = 7 print(x * 2 + 1)
Question 26
When must you use
int(input()) instead of just input()?Question 27
What happens if you define a function but never call it?
Question 28
What is the output of the following?
def message(word): print("Word: " + word) message("Python")
Question 29
What does
str() do?Question 30
Which of these would correctly print a number stored in variable
score alongside text?Question 31
How many arguments does this function call pass?
show_result(42)Question 32
What is the output of the following?
print(100 - 25 * 2)
Question 33
A function definition must end its first line with which character?
Question 34
What does the following code print?
x = 9 print(x % 4)
Question 35
The body of a Python function must be:
Question 36
What is printed by the following code?
def triple(n): print(n * 3) triple(7)
Question 37
Which correctly uses an f-string to include a variable
age in output?Question 38
What is the value of
result after: result = 5 + 3 * 2 - 1?Question 39
What does the
print() function output when called with no arguments, like print()?Question 40
Which line of code asks the user for their age and stores it as an integer?
Section B
Match the Following
10 marks
Questions 41โ45 ยท Match each item in Column A with the correct item in Column B.
Column A
41
print()42
input()43
int()44
def45
%Column B
A Converts a value to a whole number
B Displays output to the screen
C Returns the remainder of division
D Keyword to define a function
E Reads a value typed by the user
Answers:
41:
42:
43:
44:
45:
Questions 46โ50 ยท Match each Python expression with its output.
Column A โ Expression
46
10 + 547
10 - 548
10 * 549
10 ** 250
10 // 3Column B โ Output
A 3
B 100
C 50
D 5
E 15
Answers:
46:
47:
48:
49:
50:
Section C
Fill in the Blanks
10 marks
Question 51
Hint
Think about the keyword that comes before the function name when you create a function.
The keyword used to define a function in Python is .
Question 52
Hint
This built-in function always returns a string. The user types something and presses Enter.
To read input from the user we use the built-in function ().
Question 53
Hint
The operator is two asterisks together:
**. Think: "to the power of".The operator
** is used for in Python.Question 54
Hint
The function name starts with the letters int โ it converts text into a whole number.
To convert a string to a whole number, we use ().
Question 55
Hint
The function takes one argument: the person's name. Name the parameter the same as the variable used inside.
Complete the function definition with one parameter:
def welcome(): print("Hello, " + name)
Question 56
Hint
After dividing, what is left over? Example: 10 รท 3 = 3 remainder 1.
The
% operator gives the of a division.Question 57
Hint
To call a function, write its name followed by parentheses. Put the argument
"Sam" inside the brackets.To call the function
greet and pass the argument "Sam", you write: Question 58
Hint
7 รท 2 = 3 with 1 left over. The
// operator drops the decimal and keeps only the whole number.The result of
7 // 2 is .Question 59
Hint
Python uses whitespace to show which lines belong inside a function. Press Tab or use 4 spaces.
In Python, the body of a function is marked using to separate it from the rest of the code.
Question 60
Hint
This built-in function shows text on the screen. You use it every time you want the user to see something.
The built-in function that displays text to the screen is ().
Section D
Correct the Error
10 marks
Question 61
The following code has ONE error. Identify and correct it.
def sayHello(name) print("Hello, " + name)
Question 62
Find and correct the error.
age = input("Enter your age: ") print(age + 5)
Question 63
Find and correct the error.
def multiply(n): print(n * 3)
Question 64
Find and correct the error.
x = 10 y = 3 print("Result: " + x + y)
Question 65
Find and correct the error.
Def greet(name): print("Hi " + name)
Question 66
Find and correct the error.
def cube(n): print(n ^ 3)
Question 67
Find and correct the error.
num = input("Enter a number: ") result = num * 2 print(result)
Question 68
Find and correct the error.
def halve(n): print(n / 2) halve()
Question 69
Find and correct the error.
def show_area(r): area = 3.14 * r * r print("Area: " + area)
Question 70
Find and correct the error.
score = int(input("Score: ")) def check(s): print("Your score is: " + s) check(score)
Well Done!
โ / 70