What will be the output of the following Python function?
min(max(False,-3,-4), 2,7)
2
False
-3
-4
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)
7
8
6
9
Subroutines
Function
Definition
Modules
Increases code duplication
Reduces code reusability
Promotes code reusability and modularity
Makes program slower
What is the value of the following Python code?
>>>print(36 / 4)
4
9.0
4.0
A function that calls itself
A function that calls other functions
Both (A) and (B)
None of the above
reverse(l)
list(reverse[(l)])
reversed(l)
list(reversed(l))
Segments
Units
All the above
;
: :
:
%
lambda x => x+1
lambda(x): x+1
lambda x: x+1
def lambda(x): x+1
A built-in Python function
A one-line anonymous function
Lambda is a function in python but user can not use it.
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
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
Error
none of these
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
None
0
Null
Arbitary value
int
bool
void
factorial()
print()
seed()
sqrt()
import mathprint(abs(math.sqrt(25)))
-5
5
5.0
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
What will be the output of the following Python expression?
print(round(4.5676,2))
4.5
4.6
4.57
4.56
Arguments
Required Argument
Keyword Argument
Default Argument
Decimal Argument
Local Variable
Static Variable
Global Variable
Instance Variable
What will be the output?
def fun(a, b=5): print(a+b)fun(10, 20)
15
30
25
break
pass
continue
sum(2,4,6)sum([1,2,3])
Error, 6
12, Error
12, 6
Error, Error
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
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
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)
What is the output of the following code ?
def add(a, b): return a+5, b+5result = add(3,2)print(result)
(8,7)
Subtracting two numbers
Comparing two data values
Providing output to the user
Adding two numbers
Can contain multiple statements
Can have only one expression
Must use return statement
Cannot take arguments
What will be the output of the following Python code?
def foo(): return total + 1total = 0print(foo())
1
error
none of the mentioned
len(["hello",2, 4, 6])
3
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
What will be the output of following?
Y=[2,5J,6]Y.sort()
[2,6,5J]
[5J,2,6]
[6,5J,2]
Recursive Function
Lambda Function
Built-in Function
Generator Function
One
Two
Three
Any Number of Times
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)
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
find the output of following code:
def add(a,b): return(a+b)print(add(3,4))
def fun(a,b=5,c=10): print(a+b+c)fun(2,c=20)
27
17
22
Lists
Dictionary
String
All of the mentioned
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))
Calling one function from another function
Calling a function repeatedly from itself
Using nested loops
Using lambda functions
In Module
In Class
In Another function
All of these
It’s easier to code some real-world problems using recursion than non-recursive equivalent
Recursive functions are easy to debug
Recursive calls take up a lot of memory
Programs using recursion take longer time than their non-recursive equivalent