Impnenew
Impnenew
Impnenew
1) State True or False – ‘Tuple is one of the datatypes of python having data in key-value pair.”
2) State True or False “Python has a set of keywords that can also be used to declare variables.”
3) Which of the following is not a valid python operator?
a) %
b) in
c) #
d) **
4) What will be the output of the following python expression?
print(2**3**2)
a) 64
b) 256
c) 512
d) 32
5) Observe the given dictionary:
d_std={“Roll_No”:53,”Name”:’Ajay Patel’}
d_marks={“Physics”:84,”Chemistry”:85}
Which of the following statement will combine both dictionaries?
a) d_std + d_marks
b) d_std.merge(d_marks)
c) d_std.add(d_marks)
d) d_std.update(d_marks)
6) What will be the output of the following python dictionary operation?
data = {‘A’:2000, ‘B’:2500, ‘C’:3000, ‘A’:4000}
print(data)
a) {‘A’:2000, ‘B’:2500, ‘C’:3000, ‘A’:4000}
b) {‘A’:2000, ‘B’:2500, ‘C’:3000}
c) {‘A’:4000, ‘B’:2500, ‘C’:3000}
d) It will generate an error
7) What will be the output for the following expression:
not ((False and True or True) and True)
a) True
b) False
c) None
d) Null
8) What will be the output for the following expression:
print(True or not True and False)
Choose one option from the following that will be the correct output after executing the above
python expression.
a) False
b) True
c) or
d) not
9) What will be the output of the given code?
s=’CSTutorial@TutorialAICSIP’
o=s.partition(‘Tutorial’)
print(o[0]+o[2])
a) CSTutorial
b) CSTutorialAICSIP
c) CS@TutorialAICSIP
d) Tutorial@TutorialAICSIP
10) Select the correct output of the following python code:
str=”My program is program for you”
t = str.split(“program”)
print(t)
a) [‘My ‘, ‘ is ‘, ‘ for you’]
b) [‘My ‘, ‘ for you’]
c) [‘My’,’ is’]
d) [‘My’]
11) Which of the following operations on a string will generate an error?
a) “PYTHON”*2
b) “PYTHON” + “10”
c) “PYTHON” + 10
d) “PYTHON” + “PYTHON”
12) Kevin has written the following code:
d={‘EmpID’:1111,’Name’:’Ankit
Mishra’,’PayHeads’:[‘Basic’,’DA’,’TA’],’Salary’:(15123,30254,5700)} #S1
d[‘PayHeads’][2]=’HRA’ #S2
d[‘Salary’][2]=8000 #S3
print(d) #S4
But he is not getting output. Select which of the following statement has errors?
a) S1
b) S2 and S3
c) S3
d) S4
13) What will be the output of following expression in python?
print ( round (100.0 / 4 + (3 + 2.55) , 1 ) )
a) 30.0
b) 30.5
c) 30.6
d) 30.1
Fill in the Blank:
14) The explicit ___________________ of an operand to a specific type is called type casting.
a) Conversion
b) Declaration
c) Calling of Function
d) Function Header
15) Which of the following is not a core data type in Python?
a) Boolean
b) integers
c) strings
d) Class
16) What will the following code do?
dict={"Exam":"SSCE", "Year":2022}
dict.update({"Year”:2023} )
a) It will create a new dictionary dict={” Year”:2023} and an old dictionary will be deleted
b) It will throw an error and the dictionary cannot be updated
c) It will make the content of the dictionary as dict={“Exam”:”SSCE”, “Year”:2023}
d) It will throw an error and dictionary and do nothing
17) What will be the value of the expression :
4+3%5
a) 2
b) 6
c) 0
d) 7
18) Select the correct output of the code:
a= "Year 2022 at All the best"
a = a.split('2')
b = a[0] + ". " + a[1] + ". " + a[3]
print (b)
a) Year . 0. at All the best
b) Year 0. at All the best
c) Year . 022. at All the best
d) Year . 0. at all the best
19) Which of the following statement(s) would give an error after executing the following code?
S="Welcome to class XII" # Statement 1
print(S) # Statement 2
S="Thank you" # Statement 3
S[0]= '@' # Statement 4
S=S+"Thank you" # Statement 5
a) Statement 3
b) Statement 4
c) Statement 5
d) Statement 4 and 5
20) State true or false:
“A dictionary key must be of a data type that is mutable”.
21) What will be the data type of p, if p=(15)?
a) int
b) tuple
c) list
d) set
22) Which of the following is a valid identifier in python?
a) else_if
b) for
c) pass
d) 2count
23) Consider the given expression:
‘5’ or 4 and 10 and ‘bye’
Which of the following will be the correct output if the given expression is evaluated?
a) True
b) False
c)’5’
d)’bye’
24) Select the correct output of the code:
for i in "CS12":
print([i.lower()], end="#")
a) ‘c’#’s’#’1’#’2’#
b) [“cs12#’]
c) [‘c’]#[‘s’]#[‘1’]#[‘2’]#
d) [‘cs12’]#
25) Which of the following Statement(s) would give an error after executing the following code?
d={"A":1, "B": 2, "C":3, "D":4} #Statement 1
sum_keys =0 #Statement 2
for val in d.keys(): #Statement 3
sum_keys=sum_keys+val #Statement 4
print(sum_keys)
a) Statement 2
b) Statement 4
c) Statement 1
d) Statement 3
26) What will the following expression be evaluated to in Python?
print(25//4 +3**1**2*2)
a) 24
b)18
c) 6
d) 12
27) What will be the output of the following expression?
24//6%3 , 24//4//2 , 48//3//4
a) (1,3,4)
b) (0,3,4)
c) (1,12,Error)
d) (1,3,#error)
28) What will the following expression be evaluated to in Python?
print(23 + (5 + 6)**(1 + 1))
(a) 529
(b) 144
(c) 121
(d) 1936
29) Given is a Python string declaration:
message='FirstPreBoardExam@2022-23'
Write the output of: print(message[ : : -3].upper())
'322ADORSF'
30) Write the output of the code given below
d1={'rno':21, 'name':'Rajveer'}
d2={'name':'Sujal', 'age':17,'class':'XII-A'}
d2.update(d1)
print(d2.keys())
31) Predict the output of the following code:
dt=["P",10,"Q",30,"R",50]
t=0
a=""
ad=0
for i in range(1,6,2):
t=t+i
a = a + dt [i-1] + "@"
ad = ad + dt[i]
print (t, ad, a)
32) Predict the output of the given code:
L=[11,22,33,44,55]
Lst=[]
for i in range(len(L)):
if i%2==1:
t=(L[i],L[i]*2)
Lst.append(t)
print(Lst)
33) What will be the output of the following string operation?
str="PYTHON@LANGUAGE"
print(str[2:12:2])
34) Write the output of the following code.
data = [11,int(ord('a')),12,int(ord('b'))]
for x in data:
x = x + 10
print(x,end=' ')
35) Write the output of the following code and the difference between a*3 and (a,a,a)?
a=(1,2,3)
print(a*3)
print(a,a,a)
(1, 2, 3, 1, 2, 3, 1, 2, 3)
(1, 2, 3) (1, 2, 3) (1, 2, 3)
36) Write the output of the following code.
s="ComputerScience23"
n = len(s)
m=""
for i in range(0, n):
if (s[i] >= 'a' and s[i] <= 'm'):
m = m +s[i].upper()
elif (s[i]>=’n’ and s[i]<=’z’):
m = m +s[i-1]
elif (s[i].isupper()):
m=m+s[i].lower()
else:
m=m+’#’
print(m)
37) Given is a Python List declaration: lst1=[39,45,23,15,25,60]
What will be the output of print(Ist1.index(15)+2) 5
38) Write the output ot the code given below:
x=["rahul",5, B",20,30]
x.insert(1,3)
x.insert(3, "akon”)
print(x[2]) 5
39) Predict the output of the python code given below:
st= "python programming"
count=4
while True:
if st=="p":
st=st[2:]
elif st[-2]=="n":
st =st[:4]
else:
count+=1
break
print(st)
print(count)
40) Predict the output:
myvalue=["A", 40, "B", 60, "C", 20]
alpha =0
beta = ""
gama = 0
for i in range(1,6,2):
alpha +=i
beta +=myvalue[i-1]+ "#"
gama +=myvalue[i]
print(alpha, beta, gama)
41) Rewrite the following code in python after removing all syntax error(s). Underline each correction
done in the code.
Num=int(rawinput("Number:"))
sum=0
for i in range(10,Num,3)
sum+=1
if i%2=0:
print(i*2)
else:
print(i*3)
print (Sum)
42) Predict the output of the following python code:
data = [2,4,2,1,2,1,3,3,4,4]
d = {}
for x in data:
if x in d:
d[x]=d[x]+1
else:
d[x]=1
print(d)
43) Vivek has written a code to input a number and check whether it is even or odd number. His code is
having errors. Rewrite the correct code and underline the corrections made.
Def checkNumber(N):
status = N%2
return
#main-code
num=int( input(“ Enter a number to check :))
k=checkNumber(num)
if k = 0:
print(“This is EVEN number”)
else:
print(“This is ODD number”)