A function that calls other function.
A function which calls itself.
Both A and B
None of the above
fun
function
def
define
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 code?
x = 50def func (x): x = 2func (x)print ('x is now', x)
x is now 50
x is now 2
x is now 100
Error
What will be the output of the following Python function?
import mathprint(abs(math.sqrt(25)))
-5
5
5.0
What is the output of the following code ?
def fun(a, b=6): a=a+b print(a)fun(5, 4)
11
9
4
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)
int
bool
void
None
User Defined Function
Library Functions
Builtin Functions
All of the above
What is the output of below program ?
def say(message, times =1): print(message * times)say("Hello")say("Word",5)
Hello WordWordWordWordWord
Hello Word 5
Hello Word,Word,Word,Word,Word
Hello HelloHelloHelloHelloHello
What is the return type of following function ?
def func1(): return 'mnp',22print(type(func1()))
List
Dictionary
String
Tuple
built-in functions
user-defined functions
py function
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
min(max(False,-3,-4), 2,7)
2
False
-3
-4
seed()
sqrt()
factorial()
print()
Subroutines
Function
Definition
Parameters
What will be the output of the following Python code ?
def display(b,n): while n>0: print(b,end='') n=n-1display('z',3)
zzz
zz
Infinite loop
An exception is thrown
0
1
-1
A function that calls other functions
Both (A) and (B)
def s(n1): print(n1) n1=n1+2n2=4s(n2)print(n2)
6 4
4 6
4 4
6 6
What will be the output of the following Python code?
def foo(): return total + 1total = 0print(foo())
error
none of the mentioned
(x**y)**z
(x**y) / z
(x**y) % z
(x**y)*z
One
Two
Three
Any Number of Times
reverse(l)
list(reverse[(l)])
reversed(l)
list(reversed(l))
break
pass
continue
none of these
Every recursive function must have a base case
Infinite recursion can occur if the base case isn’t properly mentioned
A recursive function makes the code easier to understand
Every recursive function must have a return value
What is the output of the following?
x=123for i in x: print(i)
1 2 3
123
strptime()
strftime()
A built-in Python function
A one-line anonymous function
Lambda is a function in python but user can not use it.
What is the output of the following
y='klmn'for i in range(len(y)): print(y)
klmn klmn klmn klmn
k
kkk
None of the these
In Module
In Class
In Another function
All of these
Null
Arbitary value
def foo(fname, val): print(fname(val))foo(max, [1, 2, 3])foo(min, [1, 2, 3])
3 1
1 3
def function function_name():
declare function function_name():
def function_name():
declare function_name():
Making the code look clean
A complex task can be broken into sub-problems
Recursive calls take up less memory
Sequence generation is easier than a nested iteration
procedure
bug
None of these
Repeating a process in a loop
Calling a function from within itself
Using a loop to iterate over elements
Breaking down a problem into smaller subproblems
;
: :
:
%
What is the value of the following Python code?
>>>print(36 / 4)
9.0
4.0
example = "helle" print(example.rfind("e"))
Arguments
x='abcd'for i in x: print(i.upper())
a BCD
abcd
A B CD
A recursive function that has two base cases
A function where the recursive functions leads to an infinite loop
A recursive function where the function doesn’t return anything and just prints the values
A function where the recursive call is the last thing executed by the function
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))
Lists
All of the mentioned
A static variable
A global variable
A local variable
An automatic variable
def fun (a = 2, b = 3, c)
def fun(a = 2, b, c = 3)
def fun(a, b = 2, c = 3)
def fun(a, b, c = 3, d)
null
An exception is thrown without the return statement