Advertisement
elena_gancedo

Calculation

Jun 15th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.87 KB | None | 0 0
  1. print("Let's add some numbers")
  2. input1 = input("First number> ")
  3. input2 = input("Second number> ")
  4. result = input1 + input2
  5. print(result)
  6. print("Let's make a sum with two numbers")
  7. num1 = input("Please enter your first number:  ")   #store number as string
  8. num2 = input("Please enter your second number:  ")   #store number as string
  9. total = int(num1) + int(num2)     #cast numbers to integer to add them
  10. print(num1+ " + "+ num2+ " = "+str(total))    #cast total to string so it can be concatenated
  11. print("Let's make a subtraction with two numbers")
  12. num1 = input("Please enter your first number:  ")   #store number as string
  13. num2 = input("Please enter your second number:  ")   #store number as string
  14. total = int(num1) - int(num2)     #cast numbers to integer to subtract them
  15. print(num1+ " - "+ num2+ " = "+str(total))    #cast total to string so it can be concatenated
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement