0
0
DSA Pythonprogramming~10 mins

Bit Manipulation Basics AND OR XOR NOT Left Right Shift in DSA Python - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to perform bitwise AND of two numbers.

DSA Python
result = a [1] b
Drag options to blanks, or click blank then click option'
A^
B|
C&
D~
Attempts:
3 left
💡 Hint
Common Mistakes
Using | instead of & will perform OR operation.
Using ^ will perform XOR, not AND.
2fill in blank
medium

Complete the code to perform bitwise OR of two numbers.

DSA Python
result = x [1] y
Drag options to blanks, or click blank then click option'
A^
B|
C&
D~
Attempts:
3 left
💡 Hint
Common Mistakes
Using & instead of | will perform AND operation.
Using ^ will perform XOR, not OR.
3fill in blank
hard

Fix the error in the code to perform bitwise XOR of two numbers.

DSA Python
result = num1 [1] num2
Drag options to blanks, or click blank then click option'
A&
B|
C~
D^
Attempts:
3 left
💡 Hint
Common Mistakes
Using & or | instead of ^ will give wrong results.
Using ~ is bitwise NOT, not XOR.
4fill in blank
hard

Fill both blanks to perform left shift and right shift operations.

DSA Python
left_shift = val [1] 2
right_shift = val [2] 2
Drag options to blanks, or click blank then click option'
A<<
B>>
C&
D|
Attempts:
3 left
💡 Hint
Common Mistakes
Using & or | instead of shift operators.
Mixing up left and right shift operators.
5fill in blank
hard

Fill all three blanks to create a dictionary with keys as numbers, values as bitwise NOT of keys, and filter keys greater than 2.

DSA Python
result = { [1]: [2] for [3] in range(5) if [3] > 2 }
Drag options to blanks, or click blank then click option'
Anum
B~num
Dval
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names inconsistently.
Using & or | instead of ~ for NOT operation.