Python Programming Set 1
Computer Science Engineering (CSE),
Information Technology Engineering (IT),
Bachelor of Science in Information Technology FY (BSc IT),
Bachelor of Science in Information Technology SY (BSc IT),
Bachelor of Science in Information Technology TY (BSc IT),
Master of Science in Information Technology (MSc IT),
Master of Science in Computer Science (MSc CS),
On This Page
This set of Python Programming Multiple Choice Questions & Answers (MCQs) focuses on Python Programming Set 1
Q1 | What is the output of the following code : print 9//2
- 4.5
- 4
- 4
- Error
Q2 | Which function overloads the >> operator?
- more()
- gt()
- ge()
- rshift()
Q3 | What is the output of the following program :i = 0while i < 3:print iprint i+1
- 0 2 1 3 2 4
- 0 1 2 3 4 5
- 0 1 1 2 2 3
- 1 0 2 4 3 5
Q4 | What is the output of the following program:
- dlroW olleH
- Hello Worl
- d
- Error
Q5 | Which module in Python supports regular expressions?
- re
- regex
- pyregex
- None of the above
Q6 | What is the output of the following program :
- TRUE
- FALSE
- Machine dependent
- Error
Q7 | Which of these is not a core data type?
- Lists
- Dictionary
- Tuples
- Class
Q8 | What data type is the object below?L = [1, 23, „hello?, 1]
- List
- Dictionary
- Tuple
- Array
Q9 | What is the output of the following program :def myfunc(a):a = a + 2a = a * 2return aprint myfunc(2)
- 8
- 16
- Indentation Error
- Runtime Error
Q10 | What is the output of the expression : 3*1**3
- 27
- 9
- 3
- 1
Q11 | What is the output of the following program :print '{0:.2}'.format(1.0 / 3)
- 0.333333
- 0.33
- 0.333333:-2
- Error
Q12 | What is the output of the following program :print '{0:-2%}'.format(1.0 / 3)
- 0.33
- 0.33%
- 33.33%
- 33%
Q13 | What is the output of the following program :i = 0while i < 3:print ii += 1else:print 0
- 0 1 2 3 0
- 0 1 2 0
- 0 1 2
- Error
Q14 | What is the output of the following program :i = 0while i < 5:print(i)i += 1if i == 3:breakelse:print(0)
- 0 1 2 0
- 0 1 2
- Error
- None of the above
Q15 | What is the output of the following program : print 'cd'.partition('cd')
- („cd?)
- (”)
- („cd?, ”, ”)
- (”, „cd?, ”)
Q16 | What is the output of the following program :print 'abcefd'.replace('cd', '12')
- ab1ef2
- abcefd
- ab1efd
- ab12ed2
Q17 | What will be displayed by the following code?def f(value, values):v = 1values[0] = 44t = 3v = [1, 2, 3]f(t, v)print(t, v[0])
- 1 1
- 1 44
- 3 1
- 3 44
Q18 | Predict the output of following python programsdictionary1 = {'Google' : 1,'Facebook' : 2,'Microsoft' : 3}dictionary2 = {'GFG' : 1,'Microsoft' : 2,'Youtube' : 3}dictionary1.update(dictionary2);for key, values in dictionary1.items():print(key, values)
- Compilation error
- Runtime error
- („Google?, 1)(„Facebook?, 2)(„Youtube?, 3)(„Microsoft?, 2)(„GFG?, 1)
- None of these
Q19 | What is the output of the following program?dictionary1 = {'GFG' : 1,'Google' : 2,'GFG' : 3}print(dictionary1['GFG']);
- Compilation error due to duplicate keys
- Runtime time error due to duplicate keys
- 3
- 1
Q20 | What is the output of the following program?temp = dict()temp['key1'] = {'key1' : 44, 'key2' : 566}temp['key2'] = [1, 2, 3, 4]for (key, values) in temp.items():print(values, end = "")
- Compilation error
- {„key1?: 44, „key2?: 566}[1, 2, 3, 4]
- Runtime error
- None of the above
Q21 | What is the output of the following program?data = [2, 3, 9]temp = [[x for x in[data]] for x in range(3)]print (temp)
- [[[2, 3, 9]], [[2, 3, 9]], [[2, 3, 9]]]
- [[2, 3, 9], [2, 3, 9], [2, 3, 9]]
- [[[2, 3, 9]], [[2, 3, 9]]]
- None of these
Q22 | What is the output of the following program?data = [x for x in range(5)]temp = [x for x in range(7) if x in data and x%2==0]print(temp)
- [0, 2, 4, 6]
- [0, 2, 4]
- [0, 1, 2, 3, 4, 5]
- Runtime error
Q23 | What is the output of the following program?L1 = [1, 2, 3, 4]L2 = L1L3 = L1.copy()L4 = list(L1)L1[0] = [5]print(L1, L2, L3, L4)
- [5, 2, 3, 4] [5, 2, 3, 4] [1, 2, 3, 4] [1, 2, 3, 4]
- [[5], 2, 3, 4] [[5], 2, 3, 4] [[5], 2, 3, 4] [1, 2, 3, 4]
- [5, 2, 3, 4] [5, 2, 3, 4] [5, 2, 3, 4] [1, 2, 3, 4]
- [[5], 2, 3, 4] [[5], 2, 3, 4] [1, 2, 3, 4] [1, 2, 3, 4]
Q24 | What is the output of the following program?import sysL1 = 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))
- 0 2 3 10
- 32 34 35 42
- 48 64 72 128
- 48 144 192 480
Q25 | What is the output of the following program?T = (1, 2, 3, 4, 5, 6, 7, 8)print(T[T.index(5)], end = " ")print(T[T[T[6]-3]-6])
- 4 0
- 5 8
- 5 IndexError
- 4 1