Vidyalelo
Python · all questions

Python MCQs: Bitwise and Boolean Operations Chapter
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

60

Questions

2/3

Page

Pick an option on a question to see the right answer and solution.

What is the result of `(4 | 2) & 6` ?

Select an option to see the answer and solution.

What will be the output of the following Python code if the system date is 21st June, 2017 (Wednesday)?
[] or {}
{} or []

Select an option to see the answer and solution.

What is the result of `(8 >> 2) | (1 << 2)` ?

Select an option to see the answer and solution.

What is the result of True & False ?

Select an option to see the answer and solution.

Which of the following expressions results in an error?

Select an option to see the answer and solution.

What will be the output of the following Python code snippet if x=1?
x<<2

Select an option to see the answer and solution.

What is the result of `True | False` ?

Select an option to see the answer and solution.

What is the value of the following Python expression?
bin(0x8)

Select an option to see the answer and solution.

What will be the value of the following Python expression?
bin(10-2)+bin(12^4)

Select an option to see the answer and solution.

What is the result of `5 << 1 | 2 >> 1` ?

Select an option to see the answer and solution.

What will be the output of the following Python code snippet?
['hello', 'morning'][bool('')]

Select an option to see the answer and solution.

What will be the output of the following Python code?
if (9 < 0) and (0 < -9):
    print("hello")
elif (9 > 0) or False:
    print("good")
else:
    print("bad")

Select an option to see the answer and solution.

What will be the output of the following Python expression?
4^12

Select an option to see the answer and solution.

Which of the following expressions can be used to multiply a given number 'a' by 4?

Select an option to see the answer and solution.

What is the result of (10 >> 1) & 3 ?

Select an option to see the answer and solution.

What will be the output of the following Python code snippet?
bool(‘False’)
bool()

Select an option to see the answer and solution.

What is the result of 7 ^ 7 ?

Select an option to see the answer and solution.

What will be the output of the following Python code if a=10 and b =20?
a=10
b=20
a=a^b
b=a^b
a=a^b
print(a,b)

Select an option to see the answer and solution.

What is the result of 12 ^ (7 << 1) ?

Select an option to see the answer and solution.

What is the result of ~5 ?

Select an option to see the answer and solution.