Skip to content

Instantly share code, notes, and snippets.

@Sylvance
Last active December 5, 2018 23:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sylvance/20150649b8654015414866c9ad7b16bb to your computer and use it in GitHub Desktop.
Save Sylvance/20150649b8654015414866c9ad7b16bb to your computer and use it in GitHub Desktop.
code that takes in two numbers and adds, subtracts, multiplies and divides them and displays the result on the terminal
# Store input numbers
num1 = input('Enter first number: ')
num2 = input('Enter second number: ')
# Add two numbers
summ = float(num1) + float(num2)
# Subtract two numbers
diff = float(num1) - float(num2)
# Multiply two numbers
mult = float(num1) * float(num2)
# Divide two numbers
divi = float(num1) / float(num2)
# Display
print('The sum of {0} and {1} is {2}'.format(num1, num2, summ))
print('The difference of {0} and {1} is {2}'.format(num1, num2, diff))
print('The product of {0} and {1} is {2}'.format(num1, num2, mult))
print('The division of {0} and {1} leads to {2}'.format(num1, num2, divi))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment