Zed-King Study app · Free
O Level students across India practise here, free
Google login · no Play Store needed
About this PDF
Chapter 6 — questions on defining and calling functions, arguments, return values and the built-in string methods.
This is part of the free O Level M3-R5.1 study material in the Zed-King Study Zone. You can read every page above in your browser, or download the file and study offline. Zed-King Group of Institute is a NIELIT Study Centre in Kaithal, Haryana, and all of this material follows the current NIELIT syllabus.
- Course
- O Level — NIELIT Foundation Diploma
- Module
- M3 — M3-R5.1: Programming and Problem Solving through Python
- Section
- Chapterwise MCQ
- Format
- PDF — read online or download
- Price
- Free, no sign-up required
Text from this PDF
The opening pages as plain text — open the reader above for tables, diagrams and the full file.
Chapter-6 Function
Q1.Which statement is correct about Isalnum(). · a) Method returns true if all characters in the string are alphanumeric numbers(either alphabets or numbers).If not,it returns false · b) Method returns False if string are alphanumeric numbers(either alphabets or numbers).If not,it returns True. · c) Both of the above
Q2.What is the output of below program?
def say(message,times=1):
print(message*times)
say(‘Hello’)
say(‘World’,5)
a) Hello WorldWorldWorldWorldWorld
b) Hello World 5
c) Hello World,World,World,World,Wor
d)Hello HelloHelloHelloHelloHello
Q3.What is the output of the following?
Print(“Hello{0!r}and{0!s}”.format(‘foo’,’b in’))
a) Hello ‘foo’ and foo
b) Hello ‘foo’and foo (c ) Hello foo and ‘bin’
(d) Error
Q4. The output of the following python program is_______.
r=lambda q:q*2 s=lambda q:q*3 x=2 x=r(x)
x=s(x)
x=r(x)
print x
d) None of the above
Q5. What is the output of the following code?
def disp(*arg):
for I in arg:
print(i)
disp(name=”Rajat”, age=”20”)
a) TypeError
b) Rajat20
c) Name age
Q6. What dose the following code print?
x=’mohan’ for i in range(len(x)):
x[i].upper()
a) mohan
b) MOHAN
c) Error
Q7. What is the output of the following program?
a=2 strl= ‘(0:.4f) (0:3d) {2} (1)’ .format(a, b, c)
print(strl)
Q8. 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=” “)
Q9. What will be the output of the def func(x):
print(‘x is’ ,x)
x=2 print(‘Changed local x to’ , x)
func(x)
print(‘x is now’ ,x)
a) x is now 100
b) x is now 20
c) x is now 50
Q10. What will be the output of the x=[‘ab’ , ‘cd’] y=0 for i in x:
x[y]=i.upper()
a) [‘ab’,’cd’]
b) [‘AB’,’CD’]
c) [‘ab’,’cd’,’AB’,’CD’]
d) Error
Q11. What will be the output of the def fun1():
fun1()
c) Name Error d) None of these
Q12. What will be the output of the a=3 b=2 def change():
global b a=4 b=5 return(a*b)
print(change()*a)
b) 80 d)None of these
Q13. What will be the output of the def maximum(x,y):
if x>y:
return x elif x==y:
return ‘The numbers are equal’ return y print(maximum(2, 3))
b) The numbers are equal
Q14. What will be the output of the def increment__items(L, increment):
i=0 while i<len(L):
i=i +1 values=[1 ,2 ,3] print(increment___items(values,2))
print(values)
a) None[3,4,5]
b) None[1,2,3]
d) [3,4,5] None
Q15. The output of this Python code would be:
def find (x, **y):
print(type(y))
find(“letters”,X=’1’,Y=’2’)
a) String
b) <class ‘dict’>
c) Tuple
d) An exception is thrown
Q16.The output of this Python code would be:
>>>s.format(‘hi’,’great’,’day’)
a) ‘hi, great, and day’
b) ‘hi great and day’
c) ‘hi, great,day’
d) Error
Q17. Which one of these is NOT true about recursion? · a) We can replace a recursive function by a non-recursive function. · b) The memory space taken by the recursive functions is more than that of non-recursive function. · c) Running a recursive function is faster as compared to a non- recursive function. · d) The process of recursive makes it easier for users to understand a program.
Q18. What is the output of the following code?
def fun(a, b=6):
a=a+b print(a)
fun(5,4)
Q19. The function pow(x,y,z) is evaluated as: · a) (x**y)**z · b) (x**y)/z · d) (x**y)*z
Q20. What will be the output of the import functions m=functools.reduce(lambda x, y:x if x>y else y, l)
print(m)
a) Error
b) Address of m
Q21. 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))
Q22. What will be the output of the following code snippet?
square =lambda x: x**2 for i in range(5):
a.append(square(i))
print(a)
Q23.What will be the output of the following code snippet?
from math import * print(int(a), floor(b), ceil(c), fabs(c))
Q24.What will be the output of the def foo(k):
foo(q)
print(q)
Q25. What will be the output of the def cube(x):
return x * x* x x= cube(5)
c)125 d) None of these.
Q26. Which of the following function headers is correct? · a) def fun(a=2,b=3,c) · b) def fun(a=2,b,c=3) · c) def fun(a,b=2,c=3) · d) def fun(a,b,c=3,d)
Q27. What will be the output of the def printMax(a, b):
if a>b:
print(a, ‘is maximum’)
elif a==b:
print(a, ‘is equal to’ ,b)
print(b, ‘is maximum’)
printMax(3, 4)
c) 4 is maximum
More chapterwise mcq for M3-R5.1
Run these Python programs yourself — free
Reading code is not the same as writing it. Type any program from these notes into our free online Python compiler (real Python 3 with NumPy, input() works), or study one of the explained programs with its output.
Prepare for O Level with expert guidance
Classroom training, practical labs and exam registration at Zed-King Institute, Kaithal.
