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 = 5x = x + 1my_function()print(x)
5
6
TypeError
None
What is the output of the following code?def my_function(x, y=2):return x ** yresult1 = my_function(2)result2 = my_function(2, 3)print(result1, result2)
2 8
4 8
4 6
2 6
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]
[]
There is no difference
Parameters are values passed to a function, whereas arguments are variables defined within a function
Arguments are values passed to a function, whereas parameters are variables defined within a function
Parameters and arguments are both variables defined within a function
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 output of the following code?def my_function(*args):return sum(args)result = my_function(1, 2, 3, 4)print(result)
1
4
10
3
What is the output of the following code?def my_function(x, y):return x + yresult = my_function(y=2, x=3)print(result)
2
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
What is the output of the following code?def my_function(x, y):return x ** yresult = my_function(2, 3)print(result)
8
What is the output of the following code?def add_numbers(a, b):return a + bresult = add_numbers(5, 10)print(result)
15
50