Class Test of Function Output
Class Test of Function Output
Q2:Consider the following program. What is the correct flow of execution of statements?(1)
1 def fun1(m, n):
2 c=m+n
3 print(c)
4 return c
5 x = 10
6 y = 20
7 fun1(x,y)
8 print(“OK”)
(A) 1,2,3,4,5,6,7,8
(B) 5,6,7,1,2,3,4,8
(C) 5,6,1,2,3,4,7,8
(D) 7,8,1,2,3,4,5,6
Which is NOT the possible output of following program from given options:
import random
periph = ['Mouse', 'Keyboard', 'Printer','Monitor']
for i in range(random.randint(0,2)):
print(periph[i],'*',end=" ")
(A) Mouse *Keyboard *
(B) Mouse *
(C) Mouse *Keyboard* Printer*
(D) No output
Q4: What is the output of following program? (2)
def greet(x):
if x < 0:
return "Welcome!"
else:
return "Namaste"
print(greet(1))
print(greet(-1))
count = 1
for i in L:
if i in ['a', 'e',' i', 'o','u']:
x=x+1.swapcase ()
else:
if (count 2!=0):
x = x + str(len (L[:count]))
else:
count = count + 1 print (x)
Findoutput ()
Q13:Write the output of the code given below: (3)
s="welcome2cs"
n = len(s)
for i in range (0, n):
if (sli) >= 'a' and s[i] <= 'm'):
m = m+s[i].upper ()
elif (s[i]> 'n' and s[i] < 2):
m = m+s[i-1]
elif (s[i].isupper()):
m-m+s[i].lower ()
else:
print (m)
OR
Predict the output of the code given below: