Time left25:00 Answered 0 of 16 25 marks
MskProd Year 7 unit exam 25 minutes 25 marks Unit exam

Introduction to Python: Unit Exam A

Instructions

Time allowed
25 minutes
Total marks
25
Calculator
No calculator is permitted.
  • Answer all the questions.

Questions

25 marks
1Which line prints Hello on the screen?1 mark

Tick one box.

Mark scheme0 / 1
  • LA print("Hello")
Model answer

Python is case sensitive: it must be print in small letters, with the text in brackets and quotation marks.

Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.

Think this answer or mark scheme is wrong? Report it

2What does this program print?1 mark
Python code
age = 12
age = age + 1
print(age)

Mark scheme0 / 1
  • L13
Model answer

age starts at 12 and is replaced by 12 + 1, so 13 is printed.

Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.

Think this answer or mark scheme is wrong? Report it

3Tick one box in each row to show the data type of each value.4 marks
IntegerFloatString
42
3.5
"42"
"Hello"

Tick one box in each row.

Mark scheme0 / 4
  • L42: Integer
  • L3.5: Float
  • L"42": String
  • L"Hello": String
Model answer

Whole numbers are integers, numbers with a decimal point are floats, and anything in quotation marks is a string, even "42".

Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.

Think this answer or mark scheme is wrong? Report it

4What data type does input() always give back?1 mark

Mark scheme0 / 1
  • Lstring
Model answer

input() always returns a string, even if the user types digits.

Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.

Think this answer or mark scheme is wrong? Report it

5A program asks for the user's age with input(). Why must the answer be converted with int() before 1 is added to it?1 mark

Tick one box.

Mark scheme0 / 1
  • LD Because input() gives a string, and a number cannot be added to a string
Model answer

input() returns text. int() turns it into a whole number so that arithmetic works.

Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.

Think this answer or mark scheme is wrong? Report it

6What does this line print?1 mark
Python code
print(7 + 3 * 2)

Mark scheme0 / 1
  • L13
Model answer

Multiplication happens before addition: 3 x 2 = 6, then 7 + 6 = 13.

Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.

Think this answer or mark scheme is wrong? Report it

7What does this line print?1 mark
Python code
print("7" + "3")

Mark scheme0 / 1
  • L73
Model answer

Both are strings, so + joins them: "7" and "3" make 73.

Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.

Think this answer or mark scheme is wrong? Report it

8Complete the table to show what the program prints for each input.4 marks
Python code
temp = int(input("Temperature: "))
if temp > 25:
    print("Hot")
elif temp > 15:
    print("Warm")
else:
    print("Cold")
InputOutput
30
25
15
20

Mark scheme0 / 4
  • LHot
  • LWarm
  • LCold
  • LWarm
Model answer

30 is over 25, so Hot. 25 is not over 25 but is over 15, so Warm. 15 is not over 15, so Cold. 20 is Warm.

Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.

Think this answer or mark scheme is wrong? Report it

9Which symbol means is equal to when comparing two values?1 mark

Tick one box.

Mark scheme0 / 1
  • LB ==
Model answer

= stores a value in a variable. == compares two values.

Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.

Think this answer or mark scheme is wrong? Report it

10What is wrong with this line?print("Hello)1 mark

Tick one box.

Mark scheme0 / 1
  • LC The closing quotation mark is missing
Model answer

Every string must be closed with a matching quotation mark, so this is a syntax error.

Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.

Think this answer or mark scheme is wrong? Report it

11Why are the lines under an if statement indented?1 mark

Tick one box.

Mark scheme0 / 1
  • LA To show which lines belong to the if, so they only run when the condition is true
Model answer

Indentation shows Python which lines are inside the if.

Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.

Think this answer or mark scheme is wrong? Report it

12Write a program that asks the user for their name and then prints Hello followed by their name. For example, if the user types Mo, it prints Hello Mo3 marks
answer.py

Mark scheme0 / 3
  • LUses input() to ask for the name
  • LPrints Hello and the name that was typed in
  • LWorks for any name, because the name is stored in a variable and used in the output
A program that scores full marks

Store what input() returns in a variable, then join it to Hello in the print.

Python
name = input("What is your name? ")
print("Hello " + name)
Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.

Think this answer or mark scheme is wrong? Report it

13What does this program print?1 mark
Python code
x = 10
x = x - 4
x = x * 2
print(x)

Mark scheme0 / 1
  • L12
Model answer

x is 10, then 6, then 12.

Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.

Think this answer or mark scheme is wrong? Report it

14Explain what a variable is and why programs use them.2 marks
Explain

Mark scheme0 / 2
  • LA variable is a named location in memory that stores a value
  • LThe value can change while the program runs, and it can be used again later in the program
Model answer

A variable is a named place in memory that holds a value. Programs use variables so a value can be remembered, used again later and changed while the program runs, such as a score going up.

The marker looks for key phrases. If you said it another way and it is still right, give yourself the mark.

Think this answer or mark scheme is wrong? Report it

15Which line stores the number 5 in a variable called lives?1 mark

Tick one box.

Mark scheme0 / 1
  • LC lives = 5
Model answer

The variable name goes on the left of =, and the value on the right.

Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.

Think this answer or mark scheme is wrong? Report it

16What does this line print?1 mark
Python code
print(10 / 4)

Mark scheme0 / 1
  • L2.5
Model answer

/ is ordinary division and always gives a float: 10 / 4 = 2.5.

Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.

Think this answer or mark scheme is wrong? Report it

Machine mark 0 / 25