5yrPYQs PythonRevisionTour
5yrPYQs PythonRevisionTour
2. Rewrite the following code after removal of syntax error(s) (if any).
Underline the corrections. On making changes the logic of the
program must not be changed
A=10
B=(10,20,30)
While A%10 == 0 :
for D in range A
Print(D)
B.append(D)
3. a) Find and write the output of the following code:
def SMS(X):
L=len(X)
for t in range (L):
if (X[t] in ['a','e','i','o','u']):
X[t]="&"
elif (X[t] in ['A','E','I','O','U']):
X[t]="$"
print(X)
SMS(list("HOWAreU2019"))
answer=0
answer=CALL1(1234)
print(answer)
answer=CALL2(5678)
print(answer)
s=”Hello” #statement1
print(s*2) #statement2
s+=’independence’ #statement3
s.append(‘day’) #statement4
a. statement1
b. statement2
c. statement3
d. statement4
24. Which of the following functions is valid for both lists and
dictionaries?
a. items()
b. len()
c. update()
d. values()
Ans b. len()
The following question has been repeating since the last 3 years,
Show side panel
text=”LearningCS”
L=len(text)
ntext=””
for i in range(0,L):
if(text[i].islower()):
ntext=ntext+text[i].upper()
elif(text[i].isalnum()):
ntext=ntext+text[i-1]
else:
ntext=ntext+”&&”
print(ntext)
28. Which of the following code fragments yield the following output:
Eina
Nina
Dika
a) print(‘’’Eina
Nina
Dika’’’)
b) print(‘’’EinaNinaDika’’’)
c) print(‘Eina
Nina
Dika’)
d) print(‘Eina\nNina\nDika’)
29.
33. Dhara gets the current date and time as a string x with the value
“2021-10-30 12:49:44.216062”.Sushma prints the value of x[11:16] &
gets “12:49”.
Which of these will contain time in HH:MM:SS format?
a. x[11:19]
b. x[0:20]
c. x[11:18]
d. x[10:20]
35. mylist=[10,20,(30,40,50),60,70]
mylist.reverse()
print(mylist[1:4:2])
a. [‘Brahmi’,’is’,’well’,’known’,’promote’,’wellness’]
b. [‘Brahmi’,’is’,’known’,’promote’,’wellness’]
c. [‘Brahmi’,’is’,’known’,’to’,’mind’,’wellness’]
d. [‘Brahmi’,’is’,’known’,’mind’,’wellness’]