1.
Declare a tuple named TUP in python having following values
‘A’, 510, 5.02
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"))
b) Write the output of the following code
def CALL1(M):
t1 = M%10
t2 = M%100
t3 = t1+t2
t4 = CALL2 (t3)
return t4
def CALL2(N):
a1=N/2
a2=a1 + N//3
return a2
answer=0
answer=CALL1(1234)
print(answer)
answer=CALL2(5678)
print(answer)
4. State whether true or false
Identifiers are names used to identify a variable,function in a program.
5. Which of these is a valid keyword in python?
a. false
b. return
c. none
d. non_local
6. Given the following statement:
tup=(10,20,30,40,50)
Which of the following statements results in an error?
a. print(tup[0])
b. tup.insert(2,3)
c. print(tup[1:2])
d. print(len(tup))
7. Consider the following expression:-
5<10 and 127>7 or not 7>4
What will be its output?
a. True
b. False
c. None
d. Null
8. Which of the following statements would give an error on executing
the following code? Indicate the line number
Line code
1 stud={“Abhishek”:100,”Siddharth”:95}
2 print(stud[95])
3 stud[“Abhishek”]=99
4 print(stud.pop())
5 print(stud)
a. Statement 1
b. Statement 3
c. Statement 2
d. Statement 2 and 4
9. p=’Komal Poonam Fatima piyani’
print(p.split(‘a’))
10. p=’Komal Poonam Fatima piyani’
print(p.partition(‘a’))
11. What will be the output of the following python statement?
print(4+3*5/3-5%2)
a. 8.0
b. 8.5
c. 9
d. 10
12. Given the following list declaration in python:-
listOfNames=[‘Aman’,’Ankit’,’Akash’,’Aditya’,’Rajan’,’Rajat’]
What will be the output of: -
print(listOfNames[-1:-4:-1])
13. Given the following tuple declaration in python:-
tup1=(10,20,30,40,(10,30,20),50)
What will be the output of the following statement?
print(tup1.index(20))
14. Which of the following is not a sequential data type in python?
a. Dictionary
b. String
c. List
d. tuple
15. State if true or false:
Comments are not executed by the python interpreter.
16. Consider the following dictionary:-
Day={1:’Monday’,2:’Tuesday’,3:’Wednesday’}
What of the following will return ‘Tuesday’?
a. Day.pop()
b. Day.pop(2)
c. Day.pop(3)
d. Day.pop(‘Tuesday’)
Ans: b. Day.pop(2)
17. Consider the following statement:
7<4 or 6>3 and not 10==10 or 17>4
Give the output of the above statement?
a. True
b. False
c. None
d. null
18. Select the correct output of: -
s=’Amrit Mahotsav @ 75’
a=s.split(‘ ’,2)
print(a)
a. (‘Amrit’,’Mahotsav’,’@’,’75’)
b. [‘Amrit’, ‘Mahotsav’,’@ 75’]
c. (‘Amrit Mahotsav’,’@75’)
d. [‘Amrit’, ‘Mahotsav’,’@’,’75’]
20. Which of the following is an example of identity operators in
python?
a. in
b. not in
c. is
d. on
22. Which of the following statements would give an error after
executing the following code?
s=”Hello” #statement1
print(s*2) #statement2
s+=’independence’ #statement3
s.append(‘day’) #statement4
a. statement1
b. statement2
c. statement3
d. statement4
23. What is the output of the following statement?
print(6/3+4**3//8-4)
` a. 6.5
b. 4.0
c. 6.0
d. 4
24. Which of the following functions is valid for both lists and
dictionaries?
a. items()
b. len()
c. update()
d. values()
Ans b. len()
25. Given is a python string declaration:
name=”Learning Python is Fun”
What will be the output of:
print(name[-5:-10:-1])
The following question has been repeating since the last 3 years,
Show side panel
26. What will be the output of the code given below:-
dict1={1:[‘Rohit’,20],2:[‘Rachit’,90]}
dict2={1:[‘Rahul’,95],5:[‘Rajan’,80]}
dict1.update(dict2)
print(dict1.values())
The following question is of 2023 supplementary question paper
27. Predict the output of the following code:
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’)
a). Only a can yield the required output
b). Only a & d can yield the required output
c). Only b & c can yield the required output
d). All are incorrect
e). All are correct
29.
What is filled in blanks numbered 1,2,3 & 4?
fill#1: n1
fill#2: n
fill#3: n2
fill#4: n3
31. If you enter the number of terms in the program given in question
30 as 8, what will be the output?
a. 0,1,1,2,3,5,8,13
b. 0,1,1,2,3,5,8
c. 0,1,2,3,5,8
d. 0,1,2,3,4,5,6,7,8
32. If the value of i is 0, then the expression i!=0 evaluates to?
a. False
b. True
c. Sets the value of i to 6
d. Sets the value of i to -5
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]
34. If L=[25,17,31,13,2] is sorted by bubble sort in ascending order,
what is the correct sequence at the end of the first iteration?
a. [17,13,2,25,31]
b. [13,2,17,25,31]
c. [17,25,13,2,31]
d. [2,13,17,25,31]
35. mylist=[10,20,(30,40,50),60,70]
mylist.reverse()
print(mylist[1:4:2])
36. D=”python 4 all ”
l=[]
for i in D:
if(i.isalnum()):
l.append(i)
print(len(l))
The output of the above code is:-
a. 9
b. 2
c. 3
d. 10
37. What is output of the following code snippet:-
s=(10,20,30,40,50)
print(s.count(‘20’))
a. 0
b. 1
c. 2
d. Error
38. To create a string in python, we can put the sequence of
characters in—
a. Single quotes
b. Double quotes
c. Triple quotes
d. All of the above
39. What is output of the following code snippet:-
mystr=”Brahmi is well known to promote mind wellness”
w=mystr.split()
del w[4]
w.remove(‘well’)
w.pop(3)
print(w)
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’]
40. What is output of the following code snippet:-
ctr=0
mystr=”I love my country, I love my country”
for country in mystr:
if(country==’country’):
ctr+=1
print(ctr)
a. 0
b. 1
c. 2
d. 14
40. What is output of the following code snippet:-
ctr=0
mystr=”I love my country, I love my country”
for country in mystr:
if(country==’I’):
ctr+=1
print(ctr)
a. 0
b. 1
c. 2
d. 14
41. How do you print “country” from the given list:
s=[“India”,”is”,”my”,”country”,”I”,”love”,”my”,”country”]
a. s[3]
b. s[-5]
c. Both a & b
d. s[4]
42. What is the output of the following logical statement:
not True and False or True
a. False
b. True
c. 0
d. 1
43. What is the output of the following logical statement:
x=[[i for i in range(5)],[j for j in range(5,10)]
print(x[1][2])
a. 4
b. 3
c. 6
d. 7
44. What is output of the following code snippet:-
s=0
while(s):
str=”CBSE 2022”
print(str[2:8:2])
s-=1
a. ‘S 0’
b. ‘S 0’ many times till interrupted
c. Nothing will be printed
d. ‘ 0’
What is output of the following code snippet:-
s=2
while(s):
str=”CBSE 2022”
print(str[2:8:2])
s-=1
a. ‘S 0’
b. ‘S 0’ many times till interrupted
c. Nothing will be printed
d. ‘S 0’
‘S 0’
45. What is the output of the following code snippet:-
b=5
for a in range(5):
b-=a
print(b)
a. 5
b. 0
c. -4
d. -5
46. What is the output of the following code snippet:-
mylist1=[1,2,3,4,5,6]
mylist2.extend(mylist1)
print(mylist2)
a. mylist2 not defined will be the error message
b. mylist2 will be same as mylist1
c. No error
d. None of the above
47. Can only values without keys be printed in a python dictionary?
a. True
b. false
True
48. What is the output of the following code snippet:-
a={‘a’:’apple’,’b’:’banana’,’c’:’cashew’,’a’:’kiwi’}
a[‘a’]=’mango’
print(len(a))
a. 2
b. 3
c. 4
d. 5