Sail E0 Webinar

MCQs

Total Questions : 10
Question 1. What is the result of the expression if x=15 and y=12:
  1.    b1101
  2.    0b1101
  3.    12
  4.    1101
 Discuss Question
Answer: Option C. -> 12


The symbol '&' represents bitwise AND. This gives 1 if both the bits are equal to 1, else it gives 0. The binary form of 15 is 1111 and that of 12 is 1100. Hence on performing the bitwise AND operation, we get 1100, which is equal to 12.


Question 2. What is the output of the code shown below?not(3>4)not(1&1)
  1.    TrueTrue
  2.    TrueFalse
  3.    FalseTrue
  4.    FalseFalse
 Discuss Question
Answer: Option B. -> TrueFalse


The function not returns true if the argument amounts to false, and false if the argument amounts to true. Hence the first function returns false, and the second function returns false.


Question 3. Which of the following represents the bitwise XOR operator?
  1.    &
  2.    ^
  3.    |
  4.    !
 Discuss Question
Answer: Option B. -> ^


The ^ operator represent bitwise XOR operation. &: bitwise AND, | : bitwise OR and ! represents bitwise NOT.


Question 4. What is the value of this expression: bin(10-2)+bin(12^4)
  1.    0b10000
  2.    0b10001000
  3.    0b1000b1000
  4.    0b10000b1000
 Discuss Question
Answer: Option D. -> 0b10000b1000


The output of bin(10-2)= 0b1000 and that of bin(12^4) is ob1000. Hence the output of the above expression is: 0b10000b1000.


Question 5. What is the two's complement of -44?
  1.    1011011
  2.    11010100
  3.    11101011
  4.    10110011
 Discuss Question
Answer: Option B. -> 11010100


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).


Question 6. What is the output of the code shown below?class Truth: passx=Truth()bool(x)
  1.    pass
  2.    true
  3.    false
  4.    error
 Discuss Question
Answer: Option B. -> true


If the truth method is not defined, the object is considered true. Hence the output of the code shown above is true.


Question 7. What is the value of the following expression?2+4.00, 2**4.0
  1.    (6.0, 16.0)
  2.    (6.00, 16.00)
  3.    (6, 16)
  4.    (6.00, 16.0)
 Discuss Question
Answer: Option A. -> (6.0, 16.0)


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.


Question 8. What is the value of the expression:4+2**5//10
  1.    3
  2.    7
  3.    77
  4.    0
 Discuss Question
Answer: Option B. -> 7


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.


Question 9. What is the value of x if:x = int(43.55+2/2)
  1.    43
  2.    44
  3.    22
  4.    23
 Discuss Question
Answer: Option B. -> 44


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.


Question 10. What is the value of the following expression:24//6%3, 24//4//2
  1.    (1,3)
  2.    (0,3)
  3.    (1,0)
  4.    (3,1)
 Discuss Question
Answer: Option A. -> (1,3)


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.


Latest Videos

Latest Test Papers