by BlastRoom
Students define and call Python functions with def, pass values to parameters, trace return values and explain why functions make code reusable.
#computing#ict#cambridge_computing#cambridge_computing_stage_8
20 questions
One question set, multiple game modes. Tap any game to see it in action. Not sure which to pick?
Which keyword starts a function definition in Python?
Which line correctly starts a function called total that takes two parameters?
How do you call a function named greet that has no parameters?
A program contains only def greet(): print("Hello"). What happens when it runs?
In def area(width, height):, what are width and height?
def square(n): return n * n. When square(4) is called, what value does n take?
What does return do in a function?
def double(n): return n * 2. What does print(double(5)) show?
def add(a, b): return a + b. What does print(add(3, 4)) show?
def add(a, b): return a + b. Then x = add(2, 6) and print(x * 2). What is printed?
def greet(name): print("Hi " + name). What does greet("Mia") print?
def is_adult(age): return age >= 18. What does is_adult(15) return?
bigger(a, b) returns a if a > b, otherwise it returns b. What does bigger(3, 9) return?
def beep(): print("Beep"). The program then calls beep() three times. How many times is Beep printed?
Why do programmers put code into functions?
What is the difference between print and return inside a function?
Inside a function, a print line comes straight after a return line. What happens to the print line when the function is called?
def add(a, b): return a + b. What happens if the program calls add(5)?
Sam calls greet() on line 1 but writes def greet(): on line 5. What happens when the program runs?
Which of these is a function built into Python, so you can use it without writing def?
Outrun the horde and crack the passcode.
Pick a tile, answer, hit bonuses and steals.