Assignment 1 Python MCQ-4.5.24
Assignment 1 Python MCQ-4.5.24
(A) Tuple
(B) Array
(C) Dictionary
(D) List
2) Which of the following data type is used to store values in Key & Value format?
A) Class
(B) List
(C) Tuple
(D) Dictionary
A) [‘python’,’programming’]
B) ‘python’,’programming’
C) [‘python’]
D) [‘programming’]
5) a = 4.5
b=2
print a//b
A)2.0
B)2
C)error
D)2.5
6.)What is the output for −
S = [['him', 'sell'], [90, 28, 43]]
S[0][1][1]
A ) 'e'
B ) 'i'
C )'90'
D )h'
9.) Which of the following symbols are used for comments in Python?
(A) //
(B) ''
(C) /**/
(D) #
10) Which of the following is correct way to declare string variable in Python?
11) Python allows string slicing. What is the output of below code:
s='cppbuzz chicago'
print(s[3:5])
(A) pbuzz
(B) buzzc
(C) bu
(D) None of these
12) How to find the last element of list in Python? Assume `bikes` is the name of list.
(A) bikes[0]
(B) bikes[-1]
(C) bikes[lpos]
(D) bikes[:-1]
13) What is correct syntax to copy one list into another?
14) If a='cpp', b='buzz' then which of the following operation would show 'cppbuzz' as
output?
(A) a+b
(B) a+''+b
(C) a+""+b
(D) All of the above
16) Which one of the following is not a python's predefined data type?
(A) Class
(B) List
(C) Dictionary
(D) Tuple
data = [2, 3, 9]
temp = [[x for x in[data]] for x in range(3)]
print (temp)
a) [[[2, 3, 9]], [[2, 3, 9]], [[2, 3, 9]]]
b) [[2, 3, 9], [2, 3, 9], [2, 3, 9]]
c) [[[2, 3, 9]], [[2, 3, 9]]]
d) None of these
L1 = list()
L1.append([1, [2, 3], 4])
L1.extend([7, 8, 9])
print(L1[0][1][1] + L1[2])
a) TypeError: can only concatenate list (not “int”) to list
b) 12
c) 11
d) 38
T1 = (1)
T2 = (3, 4)
T1 += 5
print(T1)
print(T1 + T2)
a)TypeError
b) (1, 5, 3, 4)
c) 1 TypeError
d) 6 TypeError
D = dict()
for i in range (3):
for j in range(2):
D[i] = j
print(D)
a) {0: 0, 1: 0, 2: 0}
b) {0: 1, 1: 1, 2: 1}
c) {0: 0, 1: 0, 2: 0, 0: 1, 1: 1, 2: 1}
d) TypeError: Immutable object
24)import sys
L1 = tuple()
print(sys.getsizeof(L1), end = " ")
L1 = (1, 2)
print(sys.getsizeof(L1), end = " ")
L1 = (1, 3, (4, 5))
print(sys.getsizeof(L1), end = " ")
L1 = (1, 2, 3, 4, 5, [3, 4], 'p', '8', 9.777, (1, 3))
print(sys.getsizeof(L1))
a)0 2 3 10
b) 32 34 35 42
c) 48 64 72 128
d) 48 144 192 480