Advertisement
makispaiktis

Python4 - Inputs converted to integers

Apr 6th, 2019 (edited)
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. num1 = input("Enter a number: ");
  2. num2 = input("Enter another number: ");
  3. result = num1 + num2;
  4. print("By default " + str(num1) + " + " + str(num2) + " = " + str(result));                # Γιατί η Python by default παίρνει τα inputs σαν strings και μετά προσθέτει τα strings και όχι τα νούμερα ως integers
  5. result2 = float(num1) + float(num2);
  6. print("The right result is: " + str(num1) + " + " + str(num2) + " = " + str(result2));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement