Python Operators


1) Add Two Numbers

Ask the user for two numbers and print their sum.


2) Subtraction

Ask the user for two numbers and print:

first – second

3) Multiply Numbers

Ask for two numbers and print their product.


4) Division

Ask for two numbers and print:

first / second

5) Floor Division

Ask for two numbers and print:

first // second

6) Modulo Operation

Ask for two numbers and print:


7) Power Operator

Ask user for base and exponent and print:


8) Comparison – Greater Than

Ask for two numbers and print whether the first is greater than the second.


9) Comparison – Equal To

Ask for two numbers and print whether they are equal.


10) Check Even Number

Ask for a number and print:

(Use % and comparison)


11) Logical AND

Ask for two boolean-like inputs (e.g., “True”/“False”), convert them to booleans, and print:


12) Logical OR

Ask for two boolean-like inputs and print:


13) Logical NOT

Ask for one boolean input and print:


14) Increment a Number

Ask user for a number and add 1 to it using +=. Print the result.


15) Decrement a Number

Ask user for a number and subtract 1 using -=. Print result.


16) Multiply and Assign

Ask for a number and multiply it by 5 using *=. Print result.


17) Bitwise AND

Ask for two integers and print:


18) Bitwise OR

Ask for two integers and print:


19) Bitwise XOR

Ask for two integers and print:


20) Swap with Operators (Without Temp)

Ask for two numbers a and b. Swap them using a = a + b, … and print new values.


📝 Example Template

Here’s how one of these might work:


canvil: 333f6c7d-6876-4f7e-b6ad-1bdb2233f5c1

Last updated