fun
function
def
define
Local Variable
Static Variable
Global Variable
Instance Variable
In Module
In Class
In Another function
All of these
Segments
Modules
Units
All the above
Can contain multiple statements
Can have only one expression
Must use return statement
Cannot take arguments
int
bool
void
None
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
factorial()
print()
seed()
sqrt()
datetime
date
time
timedate
What is the output of the following code ?
def add(a, b): return a+5, b+5result = add(3,2)print(result)
15
8
(8,7)
Error
One
Two
Three
Any Number of Times
What is the output of following?
def test(): returnprint(test())
0
Blank
What will be the output of the following Python code?
x='abcd'for i in x: print(i.upper())
a BCD
abcd
error
A B CD
Program gets into an infinite loop
Program runs once
Program runs n number of times where n is the argument given to the function
An exception is thrown
False
float
string
depends on user input
What is the return type of following function ?
def func1(): return 'mnp',22print(type(func1()))
List
Dictionary
String
Tuple
def foo(fname, val): print(fname(val))foo(max, [1, 2, 3])foo(min, [1, 2, 3])
3 1
1 3
none of the mentioned
1
-1
2
What will be the output of the following Python expression?
print(round(4.5676,2))
4.5
4.6
4.57
4.56
def foo(): total += 1 return totaltotal = 0print(foo())
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)
Lists
All of the mentioned
What will be the output of the following python program?
def addItem(listParam): listParam+=[1]mylist=[1,2,3,4]addItem(mylist)print(len(mylist))
5
A function that calls itself
A function that calls other functions
Both (A) and (B)
None of the above
Recursive Function
Lambda Function
Built-in Function
Generator Function
At function definition
At runtime always
At function call
Never
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
What will be the output of the following Python function?
sum(2,4,6)sum([1,2,3])
Error, 6
12, Error
12, 6
Error, Error
Declared outside all functions
Declared in loop
Declared using global
Declared inside a function
What will be printed?
x = 5def f(): global x x = 10f()print(x)
10
built-in functions
user-defined functions
py function
User Defined Function
Library Functions
Builtin Functions
All of the above
function_name()
call function_name()
ret function_name()
function function_name()
reverse(l)
list(reverse[(l)])
reversed(l)
list(reversed(l))
What is the output of the following?
x=123for i in x: print(i)
1 2 3
123
none of these
#
&
*
**
def add(a, b=5): return a + bprint(add(3))
3
example = "helle" print(example.rfind("e"))
4
A static variable
A global variable
A local variable
An automatic variable
A function that calls other function.
A function which calls itself.
Both A and B
What will be the output?
def fun(a,b=2,c=3): print(a,b,c)fun(1,c=10)
1 2 10
1 10 3
1 3 10
find the output of following code:
def add(a,b): return(a+b)print(add(3,4))
7
9
x = 10def f(): x = 20 print(x)f()print(x)
10 10
20 20
20 10
Set
What is the output of this code?
def calc(x): r=2*x**2 return rprint(calc(5))
50
100
20
(x**y)**z
(x**y) / z
(x**y) % z
(x**y)*z
Heap
Stack
Uninitialized data segment
def fun(a, b=5): print(a+b)fun(10, 20)
30
25
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)