Parameters
greet() always says the same thing. So how does print print something different every time? Because we hand it information inside the parentheses. We can hand information to our own functions too — that’s called a parameter.
A function with a parameter
Section titled “A function with a parameter”Inputs (for input())
One value per line — read in order by input().
def greet(name): — name is the parameter: inside the function it works like an ordinary variable, and its value is supplied by the call. greet("Aysel") → name = "Aysel".
Several parameters
Section titled “Several parameters”Separate them with commas — order matters:
Inputs (for input())
One value per line — read in order by input().
Missions
Section titled “Missions”A personal hello
+10 XP ✓ CompletedWrite a greet function with a name parameter and call it with two different names.
Inputs (for input())
One value per line — read in order by input().
Square machine
+15 XP ✓ CompletedWrite a square(number) function — it should print the square of the number. Test it with square(4) and square(9).
Inputs (for input())
One value per line — read in order by input().
Universal times table
+15 XP ✓ CompletedMake the old times-table mission universal: times_table(number) should work for any number. Test it with times_table(7). Loop + function = 🔥
Inputs (for input())
One value per line — read in order by input().
Next lesson: instead of just printing the result, a function can return it: return. Continue →