Completed
Function Basics
Questions From This Challenge
Q1mcq1 mark
Which of the following is NOT a recognised type of function in Python as introduced in this syllabus?
Built-in function
Function defined in a module
User-defined function
Object-defined function ✓
Q2mcq1 mark
Which keyword is used to define a user-defined function in Python?
func
define
def ✓
function
Q3mcq1 mark
Which of these is an example of a built-in function?
len() ✓
greet()
calculate_area()
display_menu()
Q4mcq1 mark
What is the correct syntax to define a function named greet with no parameters?
def greet(): ✓
def greet[]:
function greet():
def greet;
Q5mcq1 mark
Which statement about user-defined functions is true?
They must always return a value
They are created using the def keyword followed by a function name ✓
They cannot be called more than once
They must be defined inside another function
Q6mcq1 mark
Which module provides the function sqrt()?
random
math ✓
statistics
string
Q7mcq1 mark
What is the term for the block of code that runs when a function is called?
function header
function body ✓
function signature
function call
Q8mcq1 mark
Which of the following correctly calls a user-defined function named add_numbers that takes two arguments?
add_numbers(2, 3) ✓
call add_numbers(2,3)
add_numbers[2,3]
def add_numbers(2,3)
Q9mcq1 mark
In the function definition below, what is radius called?
def area(radius):
return 3.14 * radius * radius
argument
parameter ✓
return value
keyword
Q10mcq1 mark
Which of the following is true about calling a function multiple times in a program?
A function can only be called once in a program
A function can be called multiple times from different parts of a program ✓
Calling a function multiple times causes an error
A function must be redefined each time before calling
Q11output1 mark
What is the output?
def greet():
print("Welcome to KVCoders")
greet()
greet()
Correct output:
Welcome to KVCoders
Welcome to KVCodersQ12output1 mark
What is the output?
def display(n):
print("Number:", n)
display(5)
display(10)
Correct output:
Number: 5
Number: 10Q13output1 mark
What is the output?
import math
def show_sqrt(x):
print(math.sqrt(x))
show_sqrt(16)
Correct output:
4.0Q14output1 mark
What is the output?
def print_square(n):
result = n * n
print(result)
print_square(6)
print_square(3)
Correct output:
36
9Q15output1 mark
What is the output?
def welcome_user(name):
message = "Hello, " + name + "!"
print(message)
welcome_user("Aisha")
Correct output:
Hello, Aisha!