Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
name = "Alice", what is f"Hi {name}"?age = 15, what is f"I am {age}"?city = "Melbourne", what is f"Welcome to {city}"?Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1name = 'Bob' print('Hi {name}') | AError: Missing f prefix | |
| 2age = 10 f'Age: {age'} | BOutput: 7 * 2 = 14 | |
| 3x = 5 f'Value: {x}' | CInvalid: Unclosed brace | |
| 4f'{2 + 2}' | DOutput: Hi Ali! | |
| 5name = 'Ali' print(f'Hi {name}!') | EValid: f-string syntax | |
| 6n = 7 print(f'{n} * 2 = {n*2}') | FOk: Expressions inside {} |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
name = "Alice" — Assigns the string Alice to the variable name.~~f"Hello {name}"greeting = f"Hello {name}"age = 12
message = f"I am {age} years old"city = "Sydney"
text = f"Welcome to {city}"score = 85
result = f"Your score: {score}"first = "Jo"
last = "Li"
full = f"{first} {last}"