McqMate
These multiple-choice questions (MCQs) are designed to enhance your knowledge and understanding in the following areas: 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) .
1. |
What is the output of the following code : print 9//2 |
A. | 4.5 |
B. | 4.0 |
C. | 4 |
D. | Error |
Answer» C. 4 |
2. |
Which function overloads the >> operator? |
A. | more() |
B. | gt() |
C. | ge() |
D. | rshift() |
Answer» D. rshift() |
3. |
What is the output of the following program :
|
A. | 0 2 1 3 2 4 |
B. | 0 1 2 3 4 5 |
C. | 0 1 1 2 2 3 |
D. | 1 0 2 4 3 5 |
Answer» C. 0 1 1 2 2 3 |
4. |
Which module in Python supports regular expressions? |
A. | re |
B. | regex |
C. | pyregex |
D. | None of the above |
Answer» A. re |
5. |
What is the output of the following program : print 0.1 + 0.2 == 0.3 |
A. | True |
B. | False |
C. | Machine dependent |
D. | Error |
Answer» B. False | |
Explanation: Neither of 0.1, 0.2 and 0.3 can be represented accurately in binary. The round off errors from 0.1 and 0.2 accumulate and hence there is a difference of 5.5511e-17 between (0.1 + 0.2) and 0.3. |
6. |
Which of these is not a core data type? |
A. | Lists |
B. | Dictionary |
C. | Tuples |
D. | Class |
Answer» D. Class |
7. |
What data type is the object below? L = [1, 23, „hello‟, 1] |
A. | List |
B. | Dictionary |
C. | Tuple |
D. | Array |
Answer» A. List |
8. |
What is the output of the following program :
|
A. | 8 |
B. | 16 |
C. | Indentation Error |
D. | Runtime Error |
Answer» C. Indentation Error |
9. |
What is the output of the expression : 3*1**3 |
A. | 27 |
B. | 9 |
C. | 3 |
D. | 1 |
Answer» C. 3 |
10. |
What is the output of the following program : print '{0:.2}'.format(1.0 / 3) |
A. | 0.333333 |
B. | 0.33 |
C. | 0.333333:-2 |
D. | Error |
Answer» B. 0.33 |
11. |
What is the output of the following program : print '{0:-2%}'.format(1.0 / 3) |
A. | 0.33 |
B. | 0.33% |
C. | 33.33% |
D. | 33% |
Answer» C. 33.33% |
12. |
What is the output of the following program :
|
A. | 0 1 2 3 0 |
B. | 0 1 2 0 |
C. | 0 1 2 |
D. | Error |
Answer» B. 0 1 2 0 |
13. |
What is the output of the following program :
|
A. | 0 1 2 0 |
B. | 0 1 2 |
C. | Error |
D. | None of the above |
Answer» B. 0 1 2 |
14. |
What is the output of the following program : print 'cd'.partition('cd') |
A. | („cd‟) |
B. | (”) |
C. | („cd‟, ”, ”) |
D. | (”, „cd‟, ”) |
Answer» D. (”, „cd‟, ”) |
15. |
What is the output of the following program : print 'abcefd'.replace('cd', '12') |
A. | ab1ef2 |
B. | abcefd |
C. | ab1efd |
D. | ab12ed2 |
Answer» B. abcefd |
16. |
What will be displayed by the following code?
|
A. | 1 1 |
B. | 1 44 |
C. | 3 1 |
D. | 3 44 |
Answer» D. 3 44 |
17. |
Predict the output of following python programs
|
A. | Compilation error |
B. | Runtime error |
C. | („Google‟, 1) („Facebook‟, 2) („Youtube‟, 3) („Microsoft‟, 2) („GFG‟, 1) |
D. | None of these |
Answer» C. („Google‟, 1) („Facebook‟, 2) („Youtube‟, 3) („Microsoft‟, 2) („GFG‟, 1) |
18. |
What is the output of the following program?
|
A. | Compilation error due to duplicate keys |
B. | Runtime time error due to duplicate keys |
C. | 3 |
D. | 1 |
Answer» C. 3 |
19. |
What is the output of the following program?
|
A. | Compilation error |
B. | {„key1‟: 44, „key2‟: 566}[1, 2, 3, 4] |
C. | Runtime error |
D. | None of the above |
Answer» B. {„key1‟: 44, „key2‟: 566}[1, 2, 3, 4] |
20. |
What is the output of the following program?
|
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 |
Answer» A. [[[2, 3, 9]], [[2, 3, 9]], [[2, 3, 9]]] |
21. |
What is the output of the following program?
|
A. | [0, 2, 4, 6] |
B. | [0, 2, 4] |
C. | [0, 1, 2, 3, 4, 5] |
D. | Runtime error |
Answer» B. [0, 2, 4] |
22. |
What is the output of the following program?
|
A. | [5, 2, 3, 4] [5, 2, 3, 4] [1, 2, 3, 4] [1, 2, 3, 4] |
B. | [[5], 2, 3, 4] [[5], 2, 3, 4] [[5], 2, 3, 4] [1, 2, 3, 4] |
C. | [5, 2, 3, 4] [5, 2, 3, 4] [5, 2, 3, 4] [1, 2, 3, 4] |
D. | [[5], 2, 3, 4] [[5], 2, 3, 4] [1, 2, 3, 4] [1, 2, 3, 4] |
Answer» D. [[5], 2, 3, 4] [[5], 2, 3, 4] [1, 2, 3, 4] [1, 2, 3, 4] |
23. |
What is the output of the following program?
|
A. | 0 2 3 10 |
B. | 32 34 35 42 |
C. | 48 64 72 128 |
D. | 48 144 192 480 |
Answer» C. 48 64 72 128 |
24. |
What is the output of the following program?
|
A. | 4 0 |
B. | 5 8 |
C. | 5 IndexError |
D. | 4 1 |
Answer» B. 5 8 |
25. |
What is the output of the following program?
|
A. | 5 None [3, 7, 9] |
B. | 5 1 [3, 7, 9] |
C. | 5 1 [3, 7, 9] |
D. | 5 None [1, 3, 7, 9] |
Answer» A. 5 None [3, 7, 9] |
26. |
What is the output of the following program?
|
A. | [1, 3.1, 5.31, 7.531] |
B. | [7.531, 5.31, 3.1, 1] |
C. | IndexError |
D. | AttributeError: „NoneType‟ object has no attribute „REVERSE‟ |
Answer» B. [7.531, 5.31, 3.1, 1] |
27. |
What is the output of the following program?
|
A. | 10.0 4.0 |
B. | 4.3588 4 |
C. | 10 .0 4 |
D. | 10.0 0 |
Answer» C. 10 .0 4 |
28. |
What is the output of the following program?
|
A. | KeyError |
B. | {0: 1, 7: 0, 1: 1, 8: 0} |
C. | {0: 0, 7: 0, 1: 1, 8: 1} |
D. | {1: 1, 7: 2, 0: 1, 8: 1} |
Answer» C. {0: 0, 7: 0, 1: 1, 8: 1} |
29. |
What is the output of the following program?
|
A. | 2 |
B. | 3 |
C. | „2‟ |
D. | KeyError |
Answer» B. 3 |
30. |
What is the output of the following program?
|
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 |
Answer» B. {0: 1, 1: 1, 2: 1} |
31. |
What is the output of the following program? from math import *
|
A. | 2 3 -4 3 |
B. | 2 3 -3 3.12 |
C. | 2 4 -3 3 |
D. | 2 3 -4 3.12 |
Answer» B. 2 3 -3 3.12 |
32. |
What is the output of the following program? |
A. | [0, „2‟, „3‟, „4‟, „5‟, 0] |
B. | [„6‟, „2‟, „3‟, „5‟, „5‟, „6‟] |
C. | [„0‟, „2‟, „3‟, „5‟, „5‟, „0‟] |
D. | [0, „2‟, „3‟, „5‟, „5‟, 0] |
Answer» D. [0, „2‟, „3‟, „5‟, „5‟, 0] |
33. |
What is the output of the following program?
|
A. | True 1 |
B. | 15 2 |
C. | (15, 2) |
D. | True 2 |
Answer» C. (15, 2) |
34. |
What is the output of the following program?
|
A. | [„What‟, „will‟, „have‟, „so‟, „will‟] |
B. | Wh t will h ve so will |
C. | What will have so will |
D. | [„Wh‟, „t will h‟, „ve so will‟] |
Answer» B. Wh t will h ve so will |
35. |
What is the type of each element in sys.argv? |
A. | set |
B. | list |
C. | tuple |
D. | string |
Answer» D. string |
36. |
What is the length of sys.argv? |
A. | number of arguments |
B. | number of arguments + 1 |
C. | number of arguments – 1 |
D. | none of the mentioned |
Answer» B. number of arguments + 1 |
37. |
What is the output of the following code?
|
A. | [0]. |
B. | [1]. |
C. | [1, 0]. |
D. | [0, 1]. |
Answer» B. [1]. |
38. |
What is the output of the following code?
|
A. | 3 1 |
B. | 1 3 |
C. | error |
D. | none of the mentioned |
Answer» A. 3 1 |
39. |
What is the output of the following?
|
A. | [1, 2, 3]. |
B. | [0, 1, 2]. |
C. | error |
D. | none of the mentioned |
Answer» C. error |
40. |
What is the output of the following?
|
A. | [1, 2, 3]. |
B. | [0, 1, 2]. |
C. | error |
D. | none of the mentioned |
Answer» A. [1, 2, 3]. |
41. |
What is the output of the following?
|
A. | [„AB‟, „CD‟]. |
B. | [„ab‟, „cd‟]. |
C. | none of the mentioned |
D. | error |
Answer» A. [„AB‟, „CD‟]. |
42. |
What is the output of the following?
|
A. | 2 |
B. | 4 |
C. | error |
D. | none of the mentioned |
Answer» A. 2 |
43. |
Program code making use of a given module is called a ______ of the module. |
A. | Client |
B. | Docstring |
C. | Interface |
D. | Modularity |
Answer» A. Client |
44. |
What is the output of the following piece of code?
|
A. | [2,4,6]. |
B. | [1,4,9]. |
C. | [2,4,6]. |
D. | There is a name clash |
Answer» D. There is a name clash |
45. |
What is the output of the following program? tday=datetime.date.today() print(tday.month()) |
A. | August |
B. | Aug |
C. | 08 |
D. | 8 |
Answer» D. 8 |
46. |
Which of the following formatting options can be used in order to add „n‟ blank spaces after a given string „S‟? |
A. | print(“-ns”%S) |
B. | print(“-ns”%S) |
C. | print(“%ns”%S) |
D. | print(“%-ns”%S) |
Answer» D. print(“%-ns”%S) |
47. |
What is the output of the following program?
|
A. | True |
B. | False |
C. | None |
D. | Error |
Answer» A. True |
48. |
To read the entire remaining contents of the file as a string from a file object infile, we use |
A. | infile.read(2) |
B. | infile.read() |
C. | infile.readline() |
D. | infile.readlines() |
Answer» B. infile.read() |
49. |
Suppose t = (1, 2, 4, 3), which of the following is incorrect? |
A. | print(t[3]) |
B. | t[3] = 45 |
C. | print(max(t)) |
D. | print(len(t)) |
Answer» B. t[3] = 45 |
Done Studing? Take A Test.
Great job completing your study session! Now it's time to put your knowledge to the test. Challenge yourself, see how much you've learned, and identify areas for improvement. Don’t worry, this is all part of the journey to mastery. Ready for the next step? Take a quiz to solidify what you've just studied.