Last active
July 24, 2022 12:13
Python Tutorials: Operators
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Arithmetic operators | |
x = 15 | |
y = 4 | |
# Output: x + y = 19 | |
print('x + y =',x+y) | |
# Output: x - y = 11 | |
print('x - y =',x-y) | |
# Output: x * y = 60 | |
print('x * y =',x*y) | |
# Output: x / y = 3.75 | |
print('x / y =',x/y) | |
# Output: x // y = 3 | |
print('x // y =',x//y) | |
# Output: x ** y = 50625 | |
print('x ** y =',x**y) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a Python Demo - Operators | |
x = 6 | |
y = 2 | |
# addition | |
print(x + y) # 8 | |
# subtraction | |
print(x - y) # 4 | |
# multiplication | |
print(x * y) # 12 | |
# division | |
print(x / y) # 3 | |
# equal to | |
print(x == y) # False | |
# not equal to | |
print(x != y) # True | |
# less than | |
print(x < y) # False | |
# and | |
print(x > 0 and y < 0) # True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment