lambda x => x+1
lambda(x): x+1
lambda x: x+1
def lambda(x): x+1
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
A function that calls itself
A function that calls other functions
Both (A) and (B)
None of the above
datetime
date
time
timedate
function
def
fun
define
What will be the output of the following Python function?
min(max(False,-3,-4), 2,7)
2
False
-3
-4
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
sum(2,4,6)sum([1,2,3])
Error, 6
12, Error
12, 6
Error, Error
1
0
none
What will be the output of the following code snippet?
numbers = (4, 7, 19, 2, 89, 45, 72, 22)sorted_numbers = sorted(numbers)odd_numbers = [x for x in sorted_numbers if x% 2!=0]print(odd_numbers)
[7, 19, 45, 89]
[2, 4, 22, 72]
[4, 7, 19, 2, 89, 45, 72, 22]
[24, 7, 19, 22, 45, 72, 89]
reverse(l)
list(reverse[(l)])
reversed(l)
list(reversed(l))
#
&
*
**
None
Null
Arbitary value
List
Tuple
Dictionary
Set
Segments
Modules
Units
All the above
(x**y)**z
(x**y) / z
(x**y) % z
(x**y)*z
What will be the output of the following Python code?
def foo(x): x = ['def', 'abc'] return id(x)q = ['abc', 'def']print(id(q) == foo(q))
True
def function function_name():
declare function function_name():
def function_name():
declare function_name():
strptime()
strftime()
Both A and B
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 s(n1): print(n1) n1=n1+2n2=4s(n2)print(n2)
6 4
4 6
4 4
6 6
Heap
Stack
Uninitialized data segment
What will be the output of the following Python expression?
print(round(4.5676,2))
4.5
4.6
4.57
4.56
A function that calls other function.
A function which calls itself.
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
int
bool
void
Subtracting two numbers
Comparing two data values
Providing output to the user
Adding two numbers
Program gets into an infinite loop
Program runs once
Program runs n number of times where n is the argument given to the function
In Module
In Class
In Another function
All of these
What will be the output of following?
Y=[2,5J,6]Y.sort()
[2,6,5J]
[5J,2,6]
[6,5J,2]
procedure
bug
None of these
Recursive Function
Lambda Function
Built-in Function
Generator 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))
What will be the output?
def fun(a,b=5,c=10): print(a+b+c)fun(2,c=20)
27
17
22
Subroutines
Function
Definition
x = 10def fun(): global x x = 20fun()print(x)
10
20
User Defined Function
Library Functions
Builtin Functions
All of the above
Increases code duplication
Reduces code reusability
Promotes code reusability and modularity
Makes program slower
def fun(a, b=5): print(a+b)fun(10, 20)
15
30
25
Local Variable
Static Variable
Global Variable
Instance Variable
What is the output of the following?
x=123for i in x: print(i)
1 2 3
123
none of these
len(["hello",2, 4, 6])
4
3
6
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 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 output of this code?
def calc(x): r=2*x**2 return rprint(calc(5))
50
100
def fun(a,b=2,c=3): print(a,b,c)fun(1,c=10)
1 2 10
1 10 3
1 3 10
One
Two
Three
Any Number of Times
Anonymous Function
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