Loading samples...
Loading samples...
py-sample-3
Master Python's Arithmetic, Logical, and Comparison Operators
What is the result of 10 % 3?
Which operator returns the quotient without remainder?
What is the output of 2 ** 4?
Which is the correct assignment operator?
What is 10 / 3 in Python 3?
Which operator is used for 'not equal to'?
What is the result of True and False?
What is 5 > 3 > 1?
Which operator has highest precedence?
What is the result of not(True or False)?
Explain the difference between / and // operators with examples.
[3 marks]What is operator precedence? Write the precedence order of arithmetic operators.
[3 marks]Differentiate between = and == operators.
[3 marks]Explain short-circuit evaluation in logical operators.
[3 marks]What are augmented assignment operators? Give 3 examples.
[3 marks]Explain membership operators in and not in with examples.
[3 marks]What is the difference between is and == operators?
[3 marks]Explain bitwise operators with any 2 examples.
[3 marks]What is the result of 5 + 3 * 2? Explain the evaluation order.
[2 marks]Explain chained comparison operators with an example.
[3 marks]Write a program to swap two numbers using arithmetic operators only (no temp variable).
[5 marks]Create a program that checks if a year is a leap year using logical operators.
[5 marks]Write a program to find the maximum of three numbers using ternary/conditional expression.
[5 marks]Create a calculator program that performs all basic operations based on user choice.
[5 marks]Write a program to demonstrate all assignment operators.
[5 marks]Create a program to check if a number is divisible by both 3 and 5.
[5 marks]Predict output: print(17 // 5) print(17 % 5) print(17 / 5)
[3 marks]Explanation:// is floor division, % is remainder, / is true division.
Find error: a = 5 b = 0 print(a // b)
[2 marks]Explanation:Cannot divide by zero. Need to check if b != 0 before dividing.
Predict output: x = 5 print(1 < x < 10) print(10 < x < 20)
[2 marks]Explanation:Chained comparisons: 1 < x AND x < 10, which is 1 < 5 < 10 = True.
Find error: result = 10 + * 5
[2 marks]Explanation:Operators need operands on both sides. The * has no left operand.
Predict output: print(True + True) print(True + False) print(False * 10)
[3 marks]Explanation:True is 1, False is 0 in numeric context.
Find error: if x = 10: print('Ten')
[2 marks]Explanation:= is assignment, == is comparison. Condition needs comparison operator.
Predict output: print(2 ** 3 ** 2) print((2 ** 3) ** 2)
[3 marks]Explanation:** is right associative: 2**(3**2)=2**9=512. With parentheses: (8)**2=64.
Find and fix: value = input('Enter: ') if value > 100: print('Big')
[3 marks]Explanation:input() returns string. Convert: value = int(input('Enter: '))