Connect with us

Python Operators: Arithmetic, Comparison, Logical

Here you can find Arithmetic, Comparison, Logical Operators example of Python:

x = 12
y = 2

# Add two operands
print('x + y =', x+y) # Result: x + y = 14

# Subtract right operand from the left
print('x - y =', x-y) # Result: x - y = 10

# Multiply two operands
print('x * y =', x*y) # Result: x * y = 24

# Divide left operand by the right one 
print('x / y =', x/y) # Result: x / y = 6

# Floor division (quotient)
print('x // y =', x//y) # Result: x // y = 6

# Remainder of the division of left operand by the right
print('x % y =', x%y) # Result: x % y = 0

# Left operand raised to the power of right (x^y)
print('x ** y =', x**y) # Result: x ** y = 144

Your Answer

Please login or Register to submit your answer
Not the answer you are looking for? Browse other questions tagged or ask your own question.

Log In

Subscribe to our newsletter

Enter your email address to subscribe to blog and receive notifications of new articles by email.
100% Privacy. No spam guaranteed