Join Now
Home Aptitude Reasoning DI VA GK CA CA Hindi Quiz Placements
What is the output of the following code?def my_function():global xx = 3x = 5my_function()print(x)
3
5
8
Error
It specifies the function name
It returns a value from the function
It defines the function arguments
It ends the function execution
What is the keyword used to define a function in Python?
define
function
def
create
What is the output of the following code?def my_function(a, b, c=0, d=0):return a + b + c + dresult = my_function(1, 2, 3, 4)print(result)
6
10
What is the output of the following code?def my_function(x, y):return x ** yresult = my_function(2, 3)print(result)
1
It allows the function to accept a variable number of keyword arguments
It allows the function to accept a variable number of positional arguments
It defines the default arguments for a function
It defines the required arguments for a function
call function_name(arguments)
function_name(arguments)
function(arguments)
call function(arguments)
What is the output of the following code?def my_function(*args):return sum(args)result = my_function(1, 2, 3, 4)print(result)
4
A function that returns a value based on a given condition
A function that calls itself
A function that performs a loop
A function that accepts a variable number of arguments
What is the output of the following code?numbers = [1, 2, 3, 4, 5]def is_even(x):return x % 2 == 0even_numbers = filter(is_even, numbers)print(list(even_numbers))
[1, 3, 5]
[2, 4]
[1, 2, 3, 4, 5]
[]