Search the courses, subjects, tracks, games and features, or jump straight to a page.
3 cards from this section. Quick, good the night before a test.
What is the keyword used to define a function in Python?
Think of how you say you are defining something in Python.
Write a simple function add(a, b) that adds two numbers.
Use the return keyword to send back a value.
What is the purpose of a function in Python?
Think about how functions can help avoid writing the same code twice.
True or False: A function can return more than one value.
Consider using a tuple when you need to return multiple results.
Write a function is_prime(num) that checks if a number is prime. Return True if it is, and False otherwise.
Consider how prime numbers are defined.
Create a function fibonacci(n) that returns a list of the first n Fibonacci numbers.
Recall how the Fibonacci sequence works.
7 more questions in this section. Enroll free to practise them all.
Enroll free