Welcome. You're about to write your very first line of Python — and I promise it's going to feel like magic. Ready?
I think so. I've always been a little scared of code. Where do we even start?
With the most famous program in all of computing. Every programmer on Earth has written this one:
print("Hello, World!")That's it. One line. When Python sees print(), it displays whatever is inside the parentheses on the screen. The text wrapped in quotes is called a string — it's just a sequence of characters.
That actually ran? I expected something way more complicated. I thought I'd need to install things and set up a whole environment first.
That's what makes Python special — it's remarkably close to plain English. And here at zuzu.codes, the environment is already set up for you. You just write, and it runs. Now, here's a question: what do you think happens if you want to greet a specific person instead of the whole world?
Maybe... put their name in the quotes? Like print("Hello, Ada!")?
Exactly right. But imagine doing that for thousands of users — you'd have to write a new line for every single name. This is where functions come in. A function is like a recipe: you give it an ingredient, and it produces something back.
def greet(name):
greeting = "Hello, " + name + "!"
return greetingBreak it down with me: def tells Python we're defining a function. greet is the name we chose. name in the parentheses is the parameter — the ingredient we hand in. Inside, we build the greeting by joining strings with +. And return hands the finished result back to whoever called the function.
Wait — what's the difference between print and return? They both seem to output something.
Great catch — this trips up almost everyone at first. print is for displaying text on the screen. return is for sending a value back so your program can use it later. Think of it this way: print is like a loudspeaker, and return is like handing someone a note. When we write tests and build real programs, we almost always want return — we want the value, not just a display.
So if I call greet("Ada"), what comes back?
Try to work it out in your head first. Python takes name = "Ada", builds "Hello, " + "Ada" + "!", and returns "Hello, Ada!". That's it — clean, predictable, reusable. You could call greet("Marie Curie") or greet("Zuzu") and it works the same way every time.
That's actually kind of beautiful. It's like a little machine.
That's exactly what it is. And you just understood one of the most important ideas in all of programming: abstraction. Instead of repeating yourself, you define the pattern once and let the function handle the rest. Now it's your turn — write greet in the editor. The tests will check three different names. Trust the process and just make them pass.
A function bundles a piece of logic under a name so you can reuse it without repeating yourself. In Python, you define one with the def keyword:
def greet(name):
return "Hello, " + name + "!"The word after def is the function's name. The words inside the parentheses are parameters — placeholders that receive values when the function is called. You call the function by writing its name followed by the actual value in parentheses: greet("Ada"). Python fills in name = "Ada" and runs the body.
return ends the function and sends a value back to the caller. Without it, Python silently returns None — a special "nothing" value. In challenge problems and real programs you almost always want an explicit return, because the automated tests compare the returned value against an expected answer.
A string is any sequence of characters wrapped in quotes. Single quotes 'hello' and double quotes "hello" are interchangeable — pick one and be consistent. Strings can be joined (concatenated) with +: "Hello, " + "world" produces "Hello, world".
Forgetting return. Writing print("Hello, " + name + "!") inside the function will display the greeting but return None. Tests that check the return value will fail.
Missing the exclamation mark. The test expects "Hello, Ada!" — with the !. An extra or missing character causes a mismatch.
Indentation matters. Python uses indentation (4 spaces) to define what's inside a function. If your return line isn't indented under def, you'll get a SyntaxError.
String concatenation with + works, but Python has a more readable alternative called f-strings:
def greet(name):
return f"Hello, {name}!"The f before the quote tells Python to treat {name} as a variable. As you progress through the track, you'll use f-strings constantly — they're cleaner and less error-prone than + joins. But the + approach you're practicing now is important to understand first, because it shows you exactly what's happening under the hood.
Sign up to write and run code in this lesson.
Welcome. You're about to write your very first line of Python — and I promise it's going to feel like magic. Ready?
I think so. I've always been a little scared of code. Where do we even start?
With the most famous program in all of computing. Every programmer on Earth has written this one:
print("Hello, World!")That's it. One line. When Python sees print(), it displays whatever is inside the parentheses on the screen. The text wrapped in quotes is called a string — it's just a sequence of characters.
That actually ran? I expected something way more complicated. I thought I'd need to install things and set up a whole environment first.
That's what makes Python special — it's remarkably close to plain English. And here at zuzu.codes, the environment is already set up for you. You just write, and it runs. Now, here's a question: what do you think happens if you want to greet a specific person instead of the whole world?
Maybe... put their name in the quotes? Like print("Hello, Ada!")?
Exactly right. But imagine doing that for thousands of users — you'd have to write a new line for every single name. This is where functions come in. A function is like a recipe: you give it an ingredient, and it produces something back.
def greet(name):
greeting = "Hello, " + name + "!"
return greetingBreak it down with me: def tells Python we're defining a function. greet is the name we chose. name in the parentheses is the parameter — the ingredient we hand in. Inside, we build the greeting by joining strings with +. And return hands the finished result back to whoever called the function.
Wait — what's the difference between print and return? They both seem to output something.
Great catch — this trips up almost everyone at first. print is for displaying text on the screen. return is for sending a value back so your program can use it later. Think of it this way: print is like a loudspeaker, and return is like handing someone a note. When we write tests and build real programs, we almost always want return — we want the value, not just a display.
So if I call greet("Ada"), what comes back?
Try to work it out in your head first. Python takes name = "Ada", builds "Hello, " + "Ada" + "!", and returns "Hello, Ada!". That's it — clean, predictable, reusable. You could call greet("Marie Curie") or greet("Zuzu") and it works the same way every time.
That's actually kind of beautiful. It's like a little machine.
That's exactly what it is. And you just understood one of the most important ideas in all of programming: abstraction. Instead of repeating yourself, you define the pattern once and let the function handle the rest. Now it's your turn — write greet in the editor. The tests will check three different names. Trust the process and just make them pass.
A function bundles a piece of logic under a name so you can reuse it without repeating yourself. In Python, you define one with the def keyword:
def greet(name):
return "Hello, " + name + "!"The word after def is the function's name. The words inside the parentheses are parameters — placeholders that receive values when the function is called. You call the function by writing its name followed by the actual value in parentheses: greet("Ada"). Python fills in name = "Ada" and runs the body.
return ends the function and sends a value back to the caller. Without it, Python silently returns None — a special "nothing" value. In challenge problems and real programs you almost always want an explicit return, because the automated tests compare the returned value against an expected answer.
A string is any sequence of characters wrapped in quotes. Single quotes 'hello' and double quotes "hello" are interchangeable — pick one and be consistent. Strings can be joined (concatenated) with +: "Hello, " + "world" produces "Hello, world".
Forgetting return. Writing print("Hello, " + name + "!") inside the function will display the greeting but return None. Tests that check the return value will fail.
Missing the exclamation mark. The test expects "Hello, Ada!" — with the !. An extra or missing character causes a mismatch.
Indentation matters. Python uses indentation (4 spaces) to define what's inside a function. If your return line isn't indented under def, you'll get a SyntaxError.
String concatenation with + works, but Python has a more readable alternative called f-strings:
def greet(name):
return f"Hello, {name}!"The f before the quote tells Python to treat {name} as a variable. As you progress through the track, you'll use f-strings constantly — they're cleaner and less error-prone than + joins. But the + approach you're practicing now is important to understand first, because it shows you exactly what's happening under the hood.