Last active
December 5, 2018 23:15
-
-
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
This file contains 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
# 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