Untitled Document
Untitled Document
var=(4)
print(type(4))
(a) <class 'list'>
(b) <class 'int'>
(c) <class 'tuple'>
(d) None of the above
5. Which of the following is not a property of a set?
(a) Ordered
(b) Mutable
(c) Does not allow duplicates
(d) All the above
6.What will be the output of the following code?
set1={1,2,3,4,5}
set1.clear()
set1
(a) Name Error
(b) Type Error
(c) set()
(d) None of the above
7. Which of the following functions cannot be applied to dictionaries?
(a) get()
(b) value()
(c) items()
(d) None of the above
8.What will be the output of the following code?
tup=(1,2,3,1,1.0,4)
print(tup.count(1))
(a) 2
(b) 3
(c) TypeError
(d) ValueError
9. Which of the following data structures are not ordered?
(a) Tuples
(b) Sets
(c) Dictionaries
(d) Both b and c
10.Which of the following does gives an error if
dic={1:’a’,2:’b’,3:’c’,’name’:’d’}?
(a) dic[1]
(b) dic.get(5)
(c) dic[4]
(d) All the above
11. Which of the following list comprehensions give the output as [1,3,5,7,9]?
(a) [i for i in range(10) if i%2==0]
(b) [i for i in range(9) if i%2==1]
(c) [i for i in range(9) if i%2==0]
(d) [i for i in range(10) if i%2==1]
12. Which of the following cannot be an element of a set?
(a) List
(b) Tuple
(c) Dictionary
(d) Both a and c
13. In the following code, what does this code print?:
sentence = "python rocks" print(sentence[2] + sentence[-3])
(a) tc
(b) "t c"
(c) "yc"
(d) "hc"
14. What would be the output of the following code?
s = 'doubled'
print(s[1:6][1:3])
A) oubleou
B) ub
C) ou
D) ubl
15. What would be the output of the following code?
s = 'completed'
print(s[2:5:3])
A) m
B) me
C) o
D) Blank Output
16. What would be the output of the following code?
s = 'coder'
print(s[::0])
A) redoc
B) coder
C) ValueError
D) IndexError
17. What would be the output of the following code?
s = 'follow'
print(s[3:8])
A) llow
B) low
C) lowlow
D) IndexError
18. Joining two strings with the + operator is called…