Search the courses, subjects, tracks, games and features, or jump straight to a page.
2 cards from this section. Quick, good the night before a test.
What keyword is used to define a function in Python?
Think of the command you give when you want the program to define a block of code.
How would you call a function named 'calculate'?
Remember to use parentheses after the function name.
What does the def keyword do in Python?
Think about the keyword used to start a function declaration.
True or False: A function can take multiple parameters.
Consider how we can pass various inputs to a function.
Create a function named compute_area that takes the radius of a circle as input and returns the area. Use the formula area = π * radius².
Remember to import the math module to access π.
Design a function is_even that takes an integer and returns True if even and False if odd. Test your function with multiple integers.
Think about using the modulus operator to determine evenness.
5 more questions in this section. Enroll free to practise them all.
Enroll free