print() with Colour.

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

print() with Colour.

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Does Colour. change the colour of the displayed text?
A True
B False
2. Should the colour name after the dot be written in quotation marks?
A False
B True
3. Should Colour start with an uppercase or lowercase C?
A Lowercase
B Uppercase
4. Should Colour.red be joined to a string with + or a comma?
A +
B Comma
5. Is COLOUR written fully in uppercase valid in this system?
A True
B False

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1print(Colour.green + "Level up!") AColour should start with an uppercase C, not lowercase colour
2print(Colour.red + "Warning!") BColour.blue
3A value joined with + to a string to change its printed colour CThe colour name should not be written in quotation marks
4The word after the dot specifying which colour to use DDisplays the text in green
5print(colour.red + "Warning!") EDisplays the text in red
6print(Colour."red" + "Game Over") FColour.

Definitions

Colour.red

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
print(______.green + "Level up!")
2.
print(Colour.___ + "Warning!")
3.
print(Colour.____ + "Great job!")
4.
_____(Colour.gold + "Score: 100")
5.
print(Colour.______ + "Bye!")

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A colour.red used in this line
B print(Colour.blue + "Hello!")
C print(Colour.green + "Great!")
Question 2
A print(Colour.gold + "Level up!")
B print(Colour."red" + "Game Over")
C print(Colour.green + "Success")
Question 3
A print(Colour.blue + "Start")
B print(Colour.orange + "Middle")
C print(Colour.purple + "End"
Question 4
A print(Colour.yellow, "Set")
B print(Colour.green + "Ready")
C print(Colour.red + "Go")
Question 5
A print(Colour.grey + "Loading...")
B print(COLOUR.red + "Error")
C print(Colour.green + "Complete")

Answer Key

print() with Colour.
Section A: Quick Questions
Q1
A — True
Q2
A — False
Q3
B — Uppercase
Q4
A — +
Q5
B — False
Section B: Match the Pairs
Q1
print(Colour.green + "Level up!") → Displays the text in green
Q2
print(Colour.red + "Warning!") → Displays the text in red
Q3
A value joined with + to a string to change its printed colour → Colour.
Q4
The word after the dot specifying which colour to use → Colour.blue
Q5
print(colour.red + "Warning!") → Colour should start with an uppercase C, not lowercase colour
Q6
print(Colour."red" + "Game Over") → The colour name should not be written in quotation marks
Section C: Definitions
Q1
Colour.red — A value joined to a string with + inside print() to change the colour of the displayed text
Section D: Fill in the Blanks
Q1
print(Colour.green + "Level up!")
Q2
print(Colour.red + "Warning!")
Q3
print(Colour.blue + "Great job!")
Q4
print(Colour.gold + "Score: 100")
Q5
print(Colour.purple + "Bye!")
Section E: Spot the Error
Q1
A — Colour must start with a capital C, not lowercase colour.
Q2
B — Colour values are not written in quotation marks — it should read Colour.red.
Q3
C — This line is missing its closing bracket — it should read print(Colour.purple + "End").
Q4
A — Colour and the string should be joined with +, not a comma — it should read Colour.yellow + "Set".
Q5
B — Only the first letter of Colour should be capitalised — it should read Colour.red, not COLOUR.red.