0% found this document useful (0 votes)
15 views6 pages

Working With Function Based Questions

The document contains a series of programming questions and code snippets related to Python, focusing on output predictions and code behavior. Each question presents a code segment followed by multiple-choice answers. The content appears to be aimed at assessing understanding of Python programming concepts.

Uploaded by

christin26sam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views6 pages

Working With Function Based Questions

The document contains a series of programming questions and code snippets related to Python, focusing on output predictions and code behavior. Each question presents a code segment followed by multiple-choice answers. The content appears to be aimed at assessing understanding of Python programming concepts.

Uploaded by

christin26sam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

TER SCIENCE (Pynon) - XII

37. What will be the output of the


following code ?
value = 50
def display (N) :
global value
value = 25
if N%7 == 0:
value = value + N
else:
value = value - N
print(value, end="#")
display (20)
print (value)
(a) 50#50 (bY50#5 (c) 50#30 (d) 5#50#
38. What will be the output of the
following code ?
import random
List ["Delhi", "Mumbai", "Chennai",
for yin range(4):
"Kolkata"]
X= random.randint (1, 3)
print (List [x],end="*")
(a) Delhi#Mumbai#Chennai#Kolkata#
(bYMumbai#Chennai#Kolkata#Mumbai#
(c)Mumbai# Mumbai #Mumbai Delhi#
#
(d)
Mumbai# Mumbai #Chennai # Mumbai
39. What is the output of the following code
snippet ?
def ChangeVal(M, N) :
for i in range(N):
if M[i]%5 ==0:
M[i]//=5
if M[i]%3 == 0:
M[i]//=3
L= (25,8,75,12]
ChangeVal(L,4)
for iin L:
print(i, end ="#*")
(a) 5#8#15#4#
(c) 5#8#15#14# by 5#845#4#
(d) 5#18#15#4#
40. Suppose content of
(d) 27
A1. Find the output of the following code :
Name = "PythoN3.1"

for x in range(len (Name) ):


if Name [x].isupper():
R= R+Name[x].1lower()
elif Name[x].islower():
R= R+Name [x]. upper()
elif Name[x].isdigit():
R= R+Name [x-1]
else:
R = R+""

print (R)
(a) pYTHOn##@ (b)pYTHOnN#@
(c) pYTHOn#® (d) pYTHOnNG#
44. What will be the output of the following code
X=3
def myfunc ():
global x
x += 2
print (x, end= ')
print(x, end=' ')
myfunc ()
print (x, end' )
(a) 3 3 3 (b) 3 4 5 (c) 3 3 5 (d) 3 55
45. Suppose content of 'Myfile.txt is
Ek Bharat Shreshtha Bharat

What will be the output of the following code ?


myfile = open("Myfile.txt")
vlist = list ("aeiouAE IOU")
VC =0

x = myfile. read()
for y in x:
if (y invlist):
VC += 1
print (vc)
myfile. close()
(a) 6 (b) 7 (c) 8 (d) 9
Suppose content of Mvfile.txt' is
What will be the output (a) 10

def change (P, Q=


produced by the following code ?
30)
P=P+Q
Q=P- Q
print(P, '#, Q)
return(P)
S= change (100)
(a) 150#50 (b) 150#100 (c) 100#70 (d) 150=70
i1. Determine the output of the following code fragments:
def create(s):
enum =

l=range ( len(s) - 1)
for nin l:
if s[n] = s[n+ 1]:
enum += s[n].upper()
else :
enum += s[n]
return enum
print(create("Excellencee") )
(b) ExCELLence (c) exCELLence (d) ExceL
(a) ExceLLenCE
t2. Given a file Ouote.txt having content as :
(a) 512, 64, 64
()512, 64, 512 (C) b4,

36. Consider the code


given below
number2 = 3):
def multiply(number1,
answer= number1 * number2
return(answer)
output = multiply (5, 5)
variable output store after the code is executed ?
What value would the
(c) 8 (d) 25
(a) 15 (b) 9
37. Consider the code given below :
def Test(aList):
result=|]
for xin aList:
if(x %2==0):
result = result + [x]
return[x]
print (Test([7, 5, 2, 8]))
What will be the output produced ?
(a) 2 (6) [2] (c) 8 (d) [8
38. Consider the following code :
import random
print(100 + random. randint(5, 1), end =')
print(100 + random. randint(5, 10), end =' )
print (100 + random.randint (5, 10), end = )
print (100 + random. randint (5, 10))
Find the suggested output options (a) to (d).
(a) 102 105 104 105 b) 110 103 104 105
105 107 105 110 ) 110 105 105 110
(a)8 (b) 36
(o) 1
What will be the output produced by the following code (d) 14
?
def change (P, Q= 30)
P= P+Q
Q=P -Q
20 o
return(P) S>3n
R= change (R, S)
print (R, '#',S)
(a) 150#50 (b150#100 (c) 100#70 (d) 150#70

1. Determine the output of the following code fragment


def evn (1):
enum =

for n inrange( len(1) ):


if n%2 ==0:
enum += l[n]
elif n %3 ==0:
enum += 1[n].upper()
return enum 'a' 'c 'd','a', 'b', 'r', 'a']))
print(evn([ 'a', 'b', 'r', (c) arACdbRa (d) arACDBra
(b) ARAcdbra
(a) arAcdbRa txt having
contents as

You might also like