← Variables & Output
Variables and f-strings
Learn
Variables and f-strings
A variable is a name you attach to a value so you can refer to it later, like a sticky label on a box. Python doesn't make you declare a type up front: you assign, and the name now points at that value.
city = "Lisbon" # the label `city` now points at the text "Lisbon"
servers = 4 # the label `servers` now points at the number 4
An f-string is a string prefixed with f, where anything inside {...} is replaced
by the value of that expression: Mad Libs for your data.
print(f"{city} runs {servers} servers") # → Lisbon runs 4 servers
Without the f, the braces are just literal characters.
Your task
Set name to "Ada" and tasks to 3, then print Ada has 3 tasks using an f-string.