PYTHON
PYTHON
2. Identify the output of the expression given below whose values are : A = 9, B =
11, C = 10, D =1, where the precedence of the operators from highest to lowest
is +,*, -,/ and all the operators are left associative. B*C+D-B-A*C/D
a) 20
b) 90
c) 110
d) 100
a. cmp(list)
b. len(list)
c. max(list)
d. length[list]
8. A = True, B = False. Choose the correct option for the following expression:
k=(A or(not B) and (A and B))
a. True
b. False
Sample= {1:”one”,2:”two”,3:”three”}
i. Sample.update({2:”Twenty”,4:”four”})
ii. Print(sample[“four”])
iii. Sample.get(1)
iv. Print(len(sample))
a) i, ii, iii
b) i, iii, iv
c) ii, iii, iv
d) i, ii, iii,iv
a. [‘ab’, ‘cd’]
b. [‘AB’, ‘CD’]
c. [None, None]
d. ERROR MESSAGE
a) print(message[7:11]+“ “+message[-5:-2])
b) print(message[5:9]+“ “+message[-5:2])
c) print(message[6:10]+“ “+message[50:])
d) print(message[-46:-50]+“ “+message[50:54])
a. 7
b. 0
c. 1
d. 7.33
13.for i in 10,21,30,40:
if(i%5 ==0):
print(i/2,end = "")
else:
print(i/3,end = "")
14.k={1,2,2,3,3,3,3,4,5}
for i in k:
print(i-1,end = "")
print(len(k),end = "")
answer : d) 012345
a) 1,2,3,4,5,6
b) 1,2,3,4,5,6,7
c) 0,1,2,3,4,5,6
d) 0,1,2,3,4,5,6,7
a) 40
b) 45
c) “john”
d) “Peter”
a) [19,21]
b) [11,15]
c) [11,15,19]
d) [13,17,21]
19.for i in 1,2,3,4,5,6:
do
if ix2 != @ then
display (i, end =)
else then
display(i-1, end = " ")
end - for
Identify the output of the pseudo code
a. 0 224466
b. 0224 46
c. 113355
d. 011335
a. iii
b. Both i and iii
c. i, ii, ii
d. ii
22.count = 10
num=5
sum=0
while (count >5 ):
sum+=count*(num-1)
Print(sum)
a) Infinite loop
b) 60
c) 55
d) 62