Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

COMPUTER SCIENCE-REVISION

SECTION – A

4. What is printed by the following statement?

D1= {“cat”:12, “dog”:6, “elephant”: “23”, “bear”:25}

Print (25 in D1).

(b) False

SECTION-B

10.Given is a python list declaration:

names = [“Aman”, “Ankit”, “Ashish”, “Rajan”, “Rajat”]

print(name[-1:-4:-1])

O/p:

Traceback (most recent call last):

File "<string>", line 2, in <module>

NameError: name 'name' is not defined. Did you mean: 'names'?

SECTION-C

13.Predict the output:

st= “python programming”

count=4

while True:

if st[0] = = ‘p’:

st=st[2:]

elif st[-2] = = ‘n’:

st=st[:4]
else:

count+=1

break

print(st)

print(count)

o/p

thon programming

SECTION-D

15.Consider the following tuples ,tuples1 and tuples2:

tuple1= (23, 1, 45, 67, 45, 9, 55, 45)

tuple2= (100,200)

Find the output of the following statements:

(i)print (tuple1.index (45))

(i) print (tuple1+tuple2)

(iii)print (sorted(tuple1))

print (tuple1)

o/p:

(2,3,1,45,67,45,9,55,45,100,200)

(1, 9, 23, 45, 45, 45, 55, 67)

(23,1,45,67,45,9,55,45)
SECTION-E

16.What will be the output of the following statements?

(i) list1=[12,32,65,26,80,10]

list1.sort()

print(list1)

(ii) list1=[1,2,3,4,5,6,7,8,9,10]

list1[::-2]

list1[:3]+list1[3:]

(iii) myList=[1,2,3,4,5,6,7,8,9,10]

del myList[3:]

print(myList)

(iv) myList=[1,2,3,4,5,6,7,8,9,10]

del myList[:5]

print(myList)

(v) myList=[1,2,3,4,5,6,7,8,9,10]

del myList[::2]

print(myList)

o/p:

(i)[10,12,26,32,65,80]

(ii) No output

(iii)[1,2,3]

(iv)[6,7,8,9,10]

(v)[2,4,6,8,10]

You might also like