Skip to content

Instantly share code, notes, and snippets.

@sojohnnysaid
Last active January 19, 2021 22:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sojohnnysaid/ae2f621e25374f5865ebff36ee8572a4 to your computer and use it in GitHub Desktop.
Save sojohnnysaid/ae2f621e25374f5865ebff36ee8572a4 to your computer and use it in GitHub Desktop.
python operators
from cs50 import get_int
# prompt the user for a number
x = get_int("Enter a number: ")
# perform arithmetic
#addition
print(f"{x} plus {x} is equal to {x + x}")
#subtraction
print(f"{x} minus {x} is equal to {x - x}")
#multiplication
print(f"{x} times {x} is equal to {x * x}")
#division
print(f"{x} divided by {x} is equal to {x / x}")
#floor-division
print(f"{x} floor-divided by {x} is equal to {x // x}")
#remainder
print(f"remainder of 100 divided by {x} is {100 % x}")
print(type(x))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment