Type Conversion, online

Six activities your students do on their own devices. See who's finished, and their scores.

Type Conversion in one minute

What students need to know

The f prefix and curly braces embed the variable value into the string. You can put expressions inside {} and Python evaluates them.

{name} is replaced by the value stored in name. The {} placeholder is replaced by the variable's value.

Mistakes students make

  • Line 2 is missing f. Should be: message = f"Hello {name}".
  • Line 2 is missing curly braces. Should be: f"I am {age} years old".
  • Line 2 uses [ ] instead of { }. Should be: f"Welcome to {city}".
  • Line 4 uses (name) instead of {name}. Should be: f"Hello {name}".

Discover other journeys with this module

What students will learn in this module

Every question in Module 11

Quick questions

  1. After name = "Alice", what is f"Hi {name}"?AHi AliceBHi {name}
  2. After age = 15, what is f"I am {age}"?AI am 15BI am {age}
  3. What letter starts an f-string?AsBf
  4. Where do variables go in f-strings?AInside {}BAfter +
  5. After city = "Melbourne", what is f"Welcome to {city}"?AWelcome to {city}BWelcome to Melbourne

Key terms

Students type the meaning of:

  • name = "Alice"
  • f"Hello {name}"
  • age = 15
  • f"I am {age} years old"

Match the pairs

name = 'Bob'
print('Hi {name}')
Match it to what it does
age = 10
f'Age: {age'}
Match it to what it does
x = 5
f'Value: {x}'
Match it to what it does
f'{2 + 2}'Match it to what it does
name = 'Ali'
print(f'Hi {name}!')
Match it to what it does
n = 7
print(f'{n} * 2 = {n*2}')
Match it to what it does

Fill in the blanks

  1. greeting = _"Hello {name}"
  2. age = 12
    message = f"I am _____ years old"
  3. city = "Sydney"
    text = f"Welcome to ______"
  4. score = 85
    result = f"Your score: {_____}"
  5. first = "Jo"
    last = "Li"
    full = f"{_____} {____}"

Spot the error

Question 1

Aname = "Alice"Bmessage = "Hello {name}"Cprint(message)

Question 2

Aage = 15Binfo = f"I am age years old"Cprint(info)

Question 3

Acity = "Melbourne"Btext = f"Welcome to [city]"Cprint(text)

Question 4

Afirst = "Bob"Blast = "Smith"Cname = f"{first} {last}"Dgreeting = f"Hello (name)"Eprint(greeting)

Question 5

Ascore = 100Bmessage = f"Score: {score}"Cage = 15Dinfo = "Age: {age}"Eprint(info)