2
1
0
none
A function that calls other function.
A function which calls itself.
Both A and B
None of the above
Segments
Modules
Units
All the above
fun
function
def
define
Subroutines
Function
Definition
Parameters
What will be the output of the following Python expression?
print(round(4.5676,2))
4.5
4.6
4.57
4.56
Choose the correct function declaration of fun1() so that we can execute the following two function calls successfully.
fun1(25, 75, 55)fun1(10, 20)
def fun1(**kwargs)
def fun1(args*)
No, it is not possible in Python
def fun1(*data)
Global Scope
Built-in Scope
Local Scope
Module Scope
What will be the output of the following Python code?
from math import factorialprint(math.factorial(5))
120
Nothing is printed
NameError: name 'math' is not defined
Error, the statement should be print factorial(5))
What is the output of following?
def add(a, b=5): return a + bprint(add(3))
3
5
8
Error
Increases code duplication
Reduces code reusability
Promotes code reusability and modularity
Makes program slower
int
bool
void
None
built-in functions
user-defined functions
py function
def foo(k): k[0] = 1 q = [0] foo(q) print(q)
[0]
[1]
[1, 0]
[0, 1]
What will be the output of the following Python function?
import mathprint(abs(math.sqrt(25)))
-5
5.0
find the output of following code:
def add(a,b): return(a+b)print(add(3,4))
4
7
9
Converts string to int
Evaluates Python expression
Prints expression
Converts to float
factorial()
print()
seed()
sqrt()
Recursive function can be replaced by a non-recursive function
Recursive functions usually take more memory space than non-recursive function
Recursive functions run faster than non-recursive function
Recursion makes programs easier to understand
def f(a, b): print(a, b)f(b=2, a=1)
2 1
1 2
What will be printed?
x = 10def f(): x = 20 print(x)f()print(x)
10 10
20 20
20 10
Local Variable
Static Variable
Global Variable
Instance Variable
function_name()
call function_name()
ret function_name()
function function_name()
User Defined Function
Library Functions
Builtin Functions
All of the above
float
string
depends on user input
What will be the output of the following?
def iq(a,b): if(a==0): return b else: return iq(a-1,a+b)print(iq(3,6))
10
11
12
What is the output of the following code ?
def fun(a, b=6): a=a+b print(a)fun(5, 4)
Required arguments
Keyword arguments
Default arguments
Variable-length arguments
def foo(x): x = ['def', 'abc'] return id(x)q = ['abc', 'def']print(id(q) == foo(q))
True
False
#
&
*
**
Heap
Stack
Uninitialized data segment
At function definition
At runtime always
At function call
Never
The variables used inside function are called local variables.
The local variables of a particular function can be used inside other functions, but these cannot be used in global space.
The variables used outside function are called global variables.
In order to change the value of global variable inside function, keyword global is used.
What is the output of the following?
x=123for i in x: print(i)
1 2 3
123
none of these
A built-in Python function
A one-line anonymous function
Lambda is a function in python but user can not use it.
A function that calls itself
A function execution instance that calls another execution instance of the same function
A class method that calls another class method
An in-built method that is automatically called
def function function_name():
declare function function_name():
def function_name():
declare function_name():
x='abcd'for i in x: print(i.upper())
a BCD
abcd
error
A B CD
What is the output of this code?
def calc(x): r=2*x**2 return rprint(calc(5))
50
100
20
Positional
Keyword
Default
Variable
null
An exception is thrown without the return statement
How many numbers will be printed by the following code?
def fun(a,b): for x in range(a,b+1): if x%3==0: print(x,end=" ")fun(100,120)
6
Null
Arbitary value
Required Argument
Keyword Argument
Default Argument
Decimal Argument
What is the output of the following code?
def s(n1): print(n1) n1=n1+2n2=4s(n2)print(n2)
6 4
4 6
4 4
6 6
Declared outside all functions
Declared in loop
Declared using global
Declared inside a function
Arguments
A function that calls other functions
Both (A) and (B)