

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) , Electrical Engineering , Civil Engineering , Mechanical Engineering .
Chapters
51. |
Which one of the following has the highest precedence in the expression? |
A. | exponential |
B. | addition |
C. | multiplication |
D. | parentheses |
Answer» D. parentheses | |
Explanation: just remember: pemdas, that is, parenthesis, exponentiation, division, multiplication, addition, subtraction. note that the precedence order of division and multiplication is the same. likewise, the order of addition and subtraction is also the same. |
52. |
Which of these in not a core data type? |
A. | lists |
B. | dictionary |
C. | tuples |
D. | class |
Answer» D. class | |
Explanation: class is a user defined data type. |
53. |
Given a function that does not return any value, What value is thrown by default when executed in shell. |
A. | int |
B. | bool |
C. | void |
D. | none |
Answer» D. none | |
Explanation: python shell throws a nonetype object back. |
54. |
Which of the following will run without errors? |
A. | round(45.8) |
B. | round(6352.898,2,5) |
C. | round() |
D. | round(7463.123,2,1) |
Answer» A. round(45.8) | |
Explanation: execute help(round) in the shell to get details of the parameters that are passed into the round function. |
55. |
What is the return type of function id? |
A. | int |
B. | float |
C. | bool |
D. | dict |
Answer» A. int | |
Explanation: execute help(id) to find out details in python shell.id returns a integer value that is unique. |
56. |
In python we do not specify types, it is
|
A. | x = 13 // 2 |
B. | x = int(13 / 2) |
C. | x = 13 % 2 |
D. | all of the mentioned |
Answer» D. all of the mentioned | |
Explanation: // is integer operation in python |
57. |
what will be the output of the following
|
A. | indentation error |
B. | cannot perform mathematical operation on strings |
C. | hello2 |
D. | hello2hello2 |
Answer» A. indentation error | |
Explanation: python codes have to be indented properly. |
58. |
What data type is the object below? L = [1, 23, 'hello', 1] |
A. | list |
B. | dictionary |
C. | array |
D. | tuple |
Answer» A. list | |
Explanation: list data type can store any |
59. |
In order to store values in terms of key and value we use what core data type. |
A. | list |
B. | tuple |
C. | class |
D. | dictionary |
Answer» D. dictionary | |
Explanation: dictionary stores values in terms of keys and values. |
60. |
Which of the following results in a SyntaxError? |
A. | ‘”once upon a time…”, she said.’ |
B. | “he said, ‘yes!\” |
C. | ‘3\\’ |
D. | ”’that’s okay”’ |
Answer» C. ‘3\\’ | |
Explanation: carefully look at the colons. |
61. |
What is the average value of the
|
A. | 85.0 |
B. | 85.1 |
C. | 95.0 |
D. | 95.1 |
Answer» A. 85.0 | |
Explanation: cause a decimal value of 0 to appear as output. |
62. |
What is the return value of trunc()? |
A. | int |
B. | bool |
C. | float |
D. | none |
Answer» A. int | |
Explanation: execute help(math.trunc) to get details. |
63. |
What is the output of 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. |
64. |
Which of the following is not a complex number? |
A. | k = 2 + 3j |
B. | k = complex(2, 3) |
C. | k = 2 + 3l |
D. | k = 2 + 3j |
Answer» C. k = 2 + 3l | |
Explanation: l (or l) stands for long. |
65. |
What is the type of inf? |
A. | boolean |
B. | integer |
C. | float |
D. | complex |
Answer» C. float | |
Explanation: infinity is a special case of floating point numbers. it can be obtained by float(‘inf’). |
66. |
What does ~4 evaluate to? |
A. | -5 |
B. | -4 |
C. | -3 |
D. | +3 |
Answer» A. -5 | |
Explanation: ~x is equivalent to -(x+1). |
67. |
What is the result of cmp(3, 1)? |
A. | 1 |
B. | 0 |
C. | true |
D. | false |
Answer» A. 1 | |
Explanation: cmp(x, y) returns 1 if x > y, 0 if x == y and -1 if x < y. |
68. |
Which of the following is incorrect? |
A. | float(‘inf’) |
B. | float(‘nan’) |
C. | float(’56’+’78’) |
D. | float(’12+34′) |
Answer» D. float(’12+34′) | |
Explanation: ‘+’ cannot be converted to a float. |
69. |
What is the result of round(0.5) – round(-0.5)? |
A. | 1.0 |
B. | 2.0 |
C. | 0.0 |
D. | value depends on python version |
Answer» D. value depends on python version | |
Explanation: the behavior of the round() |
70. |
What does 3 ^ 4 evaluate to? |
A. | 81 |
B. | 12 |
C. | 0.75 |
D. | 7 |
Answer» D. 7 | |
Explanation: ^ is the binary xor operator. |
71. |
The value of the expressions 4/(3*(2-1)) and 4/3*(2-1) is the same. |
A. | true |
B. | false |
Answer» A. true | |
Explanation: although the presence of parenthesis does affect the order of precedence, in the case shown above, it is not making a difference. the result of both of these expressions is 1.333333333. hence the statement is true. |
72. |
What will be the value of the following Python expression? 4 + 3 % 5 |
A. | 4 |
B. | 7 |
C. | 2 |
D. | 0 |
Answer» B. 7 | |
Explanation: the order of precedence is: %,+. Hence the expression above, on simplification results in 4 + 3 = 7. Hence the result is 7. |
73. |
Which of the following operators has its associativity from right to left? |
A. | + |
B. | // |
C. | % |
D. | ** |
Answer» D. ** | |
Explanation: all of the operators shown above have associativity from left to right, except exponentiation operator (**) which has its associativity from right to left. |
74. |
What will be the value of x in the
|
A. | 43 |
B. | 44 |
C. | 22 |
D. | 23 |
Answer» B. 44 | |
Explanation: The expression shown above is an example of explicit conversion. It is evaluated as int(43.55+1) = int(44.55) = 44. Hence the result of this expression is 44. |
75. |
What is the value of the following expression? 2+4.00, 2**4.0 |
A. | (6.0, 16.0) |
B. | (6.00, 16.00) |
C. | (6, 16) |
D. | (6.00, 16.0) |
Answer» A. (6.0, 16.0) | |
Explanation: the result of the expression shown above is (6.0, 16.0). this is because the result is automatically rounded off to one decimal place. |
76. |
Which of the following is the truncation division operator? |
A. | / |
B. | % |
C. | // |
Answer» C. // | |
Explanation: // is the operator for truncation division. it is called so because it returns only the integer part of the quotient, truncating the decimal part. for example: 20//3 = 6. |
77. |
What are the values of the following
|
A. | 64, 512, 64 |
B. | 64, 64, 64 |
C. | 512, 512, 512 |
D. | 512, 64, 512 |
Answer» D. 512, 64, 512 | |
Explanation: Expression 1 is evaluated as: 2**9, which is equal to 512. Expression 2 is evaluated as 8**2, which is equal to 64. The last expression is evaluated as 2**(3**2). This is because the associativity of ** operator is from right to left. Hence the result of the third expression is 512. |
78. |
What is the value of the following expression? 8/4/2, 8/(4/2) |
A. | (1.0, 4.0) |
B. | (1.0, 1.0) |
C. | (4.0. 1.0) |
D. | (4.0, 4.0) |
Answer» A. (1.0, 4.0) | |
Explanation: the above expressions are evaluated as: 2/2, 8/2, which is equal to (1.0, 4.0). |
79. |
What will be the value of X in the
|
A. | 30.0 |
B. | 30.8 |
C. | 28.4 |
D. | 27.2 |
Answer» D. 27.2 | |
Explanation: The expression shown above is evaluated as: 2+9*(36-8)/10, which simplifies to give 2+9*(2.8), which is equal to 2+25.2 =27.2. Hence the result of this expression is 27.2. |
80. |
What will be the output of the following
|
A. | (1,3) |
B. | (0,3) |
C. | (1,0) |
D. | (3,1) |
Answer» A. (1,3) | |
Explanation: the expressions are evaluated as: 4%3 and 6//2 respectively. this results in the answer (1,3). this is because the associativity of both of the expressions shown above is left to right. |
81. |
What will be the value of the following
|
A. | 5.0 |
B. | 5 |
C. | 4.0 |
D. | 4 |
Answer» C. 4.0 | |
Explanation: the above expression is an example of explicit conversion. it is evaluated as: float(4+int(2.39)%2) = float(4+2%2) = float(4+0) = 4.0. hence the result of this expression is 4.0. |
82. |
What will be the value of the following
|
A. | 3 |
B. | 7 |
C. | 77 |
D. | 0 |
Answer» B. 7 | |
Explanation: The order of precedence is: **, //, +. The expression 4+2**5//10 is evaluated as 4+32//10, which is equal to 4+3 = 7. Hence the result of the expression shown above is 7. |
83. |
The expression 2**2**3 is evaluates as: (2**2)**3. |
A. | true |
B. | false |
Answer» B. false | |
Explanation: the value of the expression (2**2)**3 = 4**3 = 64. when the expression 2**2**3 is evaluated in python, we get the result as 256, because this expression is evaluated as 2**(2**3). this is because the associativity of exponentiation operator (**) is from right to left and not from left to right. |
84. |
What will be the output of the following Python expression? int(1011)? |
A. | 1011 |
B. | 11 |
C. | 13 |
D. | 1101 |
Answer» A. 1011 | |
Explanation: the result of the expression shown will be 1011. this is because we have not specified the base in this expression. |
85. |
Which of the following expressions results in an error? |
A. | int(1011) |
B. | int(‘1011’,23) |
C. | int(1011,2) |
D. | int(‘1011’) |
Answer» C. int(1011,2) | |
Explanation: the expression int(1011,2) results in an error. had we written this expression as int(‘1011’,2), then there would not be an error. |
86. |
Which of the following represents the bitwise XOR operator? |
A. | & |
B. | ^ |
D. | ! |
Answer» B. ^ | |
Explanation: the ^ operator represent bitwise xor operation. &: bitwise and, |
87. |
What is the value of the following Python expression? bin(0x8) |
A. | ‘0bx1000’ |
B. | 8 |
C. | 1000 |
D. | ‘0b1000’ |
Answer» D. ‘0b1000’ | |
Explanation: the prefix 0x specifies that the value is hexadecimal in nature. when we convert this hexadecimal value to binary form, we get the result as: ‘0b1000’. |
88. |
What will be the output of the following Python expression? 0x35 | 0x75 |
A. | 115 |
B. | 116 |
C. | 117 |
D. | 118 |
Answer» C. 117 | |
Explanation: the binary value of 0x35 is 110101 and that of 0x75 is 1110101. on or- ing these two values we get the output as: 1110101, which is equal to 117. hence the result of the above expression is 117. |
89. |
It is not possible for the two’s complement value to be equal to the original value in any case. |
A. | true |
B. | false |
Answer» B. false | |
Explanation: in most cases the value of two’s |
90. |
Bitwise gives 1 if either of the bits is 1 and 0 when both of the bits are 1. |
A. | or |
B. | and |
C. | xor |
D. | not |
Answer» C. xor | |
Explanation: bitwise xor gives 1 if either of the bits is 1 and 0 when both of the bits are 1. |
91. |
What will be the output of the following
|
A. | 2 |
B. | 4 |
C. | 8 |
D. | 12 |
Answer» C. 8 | |
Explanation: ^ is the xor operator. the binary form of 4 is 0100 and that of 12 is 1100. therefore, 0100^1100 is 1000, which is equal to 8. |
92. |
Which of the following expressions can be used to multiply a given number ‘a’ by 4? |
A. | a<<2 |
B. | a<<4 |
C. | a>>2 |
D. | a>>4 |
Answer» A. a<<2 | |
Explanation: let us consider an example wherein a=2. the binary form of 2 is 0010. when we left shift this value by 2, we get 1000, the value of which is 8. hence if we want to multiply a given number ‘a’ by 4, we can use the expression: a<<2. |
93. |
R operator. Hence the output of the code shown above is: 20 10. |
A. | 1011011 |
B. | 11010100 |
C. | 11101011 |
D. | 10110011 |
Answer» B. 11010100 | |
Explanation: the binary form of -44 is 00101100. the one’s complement of this value is 11010011. on adding one to this we get: 11010100 (two’s complement). |
94. |
What will be the output of the following
|
A. | true |
B. | false |
C. | error |
D. | no output |
Answer» B. false | |
Explanation: the expression not(10<20) returns false. the expression not(10>30) returns true. the and operation between false and true returns false. hence the output is false. |
95. |
What will be the output of the following
|
A. | 0 |
B. | no output |
C. | error |
D. | none of the mentioned |
Answer» B. no output | |
Explanation: range(0) is empty. |
96. |
What will be the output of the following
|
A. | 0.0 1.0 |
B. | 0 1 |
C. | error |
D. | none of the mentioned |
Answer» C. error | |
Explanation: object of type float cannot be interpreted as an integer. |
97. |
What will be the output of the following
|
A. | 0.0 1.0 |
B. | 0 1 |
C. | error |
D. | none of the mentioned |
Answer» B. 0 1 | |
Explanation: range(int(2.0)) is the same as range(2). |
98. |
What will be the output of the following
|
A. | 0 1 2 3 |
B. | 0 1 2 2 |
C. | 3 3 3 3 |
D. | error |
Answer» A. 0 1 2 3 | |
Explanation: the value of a[0] changes in each iteration. since the first value that it takes is itself, there is no visible error in the current example. |
99. |
What will be the output of the following
|
A. | a |
B. | bc |
C. | bca |
D. | abc |
Answer» D. abc | |
Explanation: + operator is concatenation operator. |
100. |
What will be the output of the following
|
A. | a |
B. | ab |
C. | cd |
D. | dc |
Answer» C. cd | |
Explanation: slice operation is performed on string. |
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.