(x**y)**z
(x**y) / z
(x**y) % z
(x**y)*z
datetime
date
time
timedate
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 will be the output of the following Python code?
def foo(): total += 1 return totaltotal = 0print(foo())
0
1
error
none of the mentioned
break
pass
continue
none of these
def foo(): return total + 1total = 0print(foo())
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
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
What is the output of the following code ?
def fun(a, b=6): a=a+b print(a)fun(5, 4)
11
9
5
4
One
Two
Three
Any Number of Times
x='abcd'for i in x: print(i.upper())
a BCD
abcd
A B CD
What is the output of the following?
x=123for i in x: print(i)
1 2 3
123
Error
2
none
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
User Defined Function
Library Functions
Builtin Functions
All of the above
A function that calls itself
A function that calls other functions
Both (A) and (B)
None of the above
def add(a, b): return a+5, b+5result = add(3,2)print(result)
15
8
(8,7)
built-in functions
user-defined functions
py function
What will be the output of following?
Y=[2,5J,6]Y.sort()
[2,6,5J]
[5J,2,6]
[6,5J,2]
procedure
function
bug
None of these
def disp(*arg): for i in arg: print(i)disp(name="Rajat", age="20")
TypeError
Rajat 20
Name age
def foo(k): k[0] = 1 q = [0] foo(q) print(q)
[0]
[1]
[1, 0]
[0, 1]
Segments
Modules
Units
All the above
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]
Heap
Stack
Uninitialized data segment
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)
reverse(l)
list(reverse[(l)])
reversed(l)
list(reversed(l))
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
Required arguments
Keyword arguments
Default arguments
Variable-length arguments
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
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
A function that calls other function.
A function which calls itself.
Both A and B
-1
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 code?
def s(n1): print(n1) n1=n1+2n2=4s(n2)print(n2)
6 4
4 6
4 4
6 6
Subtracting two numbers
Comparing two data values
Providing output to the user
Adding two numbers
In Module
In Class
In Another function
All of these
function_name()
call function_name()
ret function_name()
function function_name()
Define keyword in python
Define variable in python
Define function in python
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
6
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
fun
def
define
example = "helle" print(example.rfind("e"))
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
def function function_name():
declare function function_name():
def function_name():
declare function_name():
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.
Subroutines
Function
Definition
int
null
None
An exception is thrown without the return statement
Lists
Dictionary
String
All of the mentioned
seed()
sqrt()
factorial()
print()