Skip to content

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.

Inputs (for input())

One value per line — read in order by input().

Output
 

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".

Separate them with commas — order matters:

Inputs (for input())

One value per line — read in order by input().

Output
 
Mission

A personal hello

+10 XP

Write 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().

Output
 
Mission

Square machine

+15 XP

Write 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().

Output
 
Mission

Universal times table

+15 XP

Make 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().

Output
 

Next lesson: instead of just printing the result, a function can return it: return. Continue →