IDE function: prettyprint

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

IDE function: prettyprint

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. What does prettyprint do in an IDE?
A Shows code in a clear layout using colours and indentation
B Translates the code into machine code
2. Prettyprint changes the instructions in a student's program so they run faster.
A False
B True
3. In prettyprint, keywords such as IF and WHILE are usually shown...
A Deleted from the code to save space
B In a different colour from other text
4. Which is a benefit of prettyprint?
A Code is easier to read and errors are easier to spot
B Code no longer needs to be compiled
5. How does prettyprint show a block of code inside a loop?
A It puts the block in a separate file
B It indents the block

Match the Pairs

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

Left columnRight column
1if x > 5: print(x) Afor i in range(3): print(i)
2# add the scores Bprint("Hi") # same output with or without colours
3Prettyprint uses indentation to show which lines belong inside a block such as a loop CPrettyprint only changes the display. It does not change the code or make it run faster.
4Prettyprint is layout only: it changes how code looks on screen, not what the code does DPrettyprint shows a comment in its own colour, so it stands out from the code that runs.
5Prettyprint rewrites your code so that it runs faster. EPrettyprint does not fix errors. It only makes the code easier to read so the student can spot errors more easily.
6Prettyprint finds and fixes the errors in your program. FPrettyprint shows the keyword if in a colour and indents the line inside the block, so the structure is easy to see.

Definitions

prettyprint

Fill in the Blanks

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

1.
# ___________ colours keywords in the editor
2.
__ score > 50: print("Pass")
3.
FOR i ← 1 TO 3 OUTPUT i ____ i
4.
_ Comments get their own colour print("Hi")
5.
# Prettyprint changes layout, not the ____

Spot the Error

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

Question 1
A Prettyprint colours comments
B score = 10
C if score > 5:
D print("Pass")
Question 2
A name = "Sam"
B print("Hello + name)
C print(name)
Question 3
A for i in range(3):
B print(i)
C if i == 2:
D prnit("Done")
Question 4
A total = 0
B for n in [1, 2, 3]:
C total = total + n)
D print(total)
Question 5
A age = 16
B If age >= 16:
C print("Can drive")

Answer Key

IDE function: prettyprint
Section A: Quick Questions
Q1
A — Shows code in a clear layout using colours and indentation
Q2
A — False
Q3
B — In a different colour from other text
Q4
A — Code is easier to read and errors are easier to spot
Q5
B — It indents the block
Section B: Match the Pairs
Q1
if x > 5: print(x) → Prettyprint shows the keyword if in a colour and indents the line inside the block, so the structure is easy to see.
Q2
# add the scores → Prettyprint shows a comment in its own colour, so it stands out from the code that runs.
Q3
Prettyprint uses indentation to show which lines belong inside a block such as a loop → for i in range(3): print(i)
Q4
Prettyprint is layout only: it changes how code looks on screen, not what the code does → print("Hi") # same output with or without colours
Q5
Prettyprint rewrites your code so that it runs faster. → Prettyprint only changes the display. It does not change the code or make it run faster.
Q6
Prettyprint finds and fixes the errors in your program. → Prettyprint does not fix errors. It only makes the code easier to read so the student can spot errors more easily.
Section C: Definitions
Q1
prettyprint — An IDE feature that shows code in a clear layout, using colours for keywords and indentation for blocks, so it is easy to read. It changes only the display, not the code.
Section D: Fill in the Blanks
Q1
# prettyprint colours keywords in the editor
Q2
if score > 50: print("Pass")
Q3
FOR i ← 1 TO 3 OUTPUT i NEXT i
Q4
# Comments get their own colour print("Hi")
Q5
# Prettyprint changes layout, not the code
Section E: Spot the Error
Q1
A — The comment is missing its # symbol, so it is treated as code and will not be shown in the comment colour. It should be '# Prettyprint colours comments'.
Q2
B — The closing quote is missing, so prettyprint would colour the rest of the line as one string. It should be print("Hello " + name).
Q3
D — The function name print is misspelled. Prettyprint colours the real function name, so the misspelling stands out as uncoloured. It should be print("Done").
Q4
C — There is a stray closing bracket at the end of the line. A prettyprinted layout makes this easier to spot. It should be ' total = total + n'.
Q5
B — Keywords are case-sensitive, so 'If' would not be shown in the keyword colour. The keyword should be lowercase: if age >= 16: