tuomasvaltanen

Untitled

Sep 14th, 2022
950
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.31 KB | None | 0 0
  1. print("Hello world!")
  2.  
  3. age = 29
  4. print(age)
  5.  
  6. age_text = str(age)
  7. print("Your age:" + age_text)
  8.  
  9. salary = 3500
  10. print(salary)
  11.  
  12. tax = 1.24
  13. print(tax)
  14.  
  15. name = "Some Person"
  16. print(name)
  17.  
  18. total = 153 + 869
  19. print(total)
  20.  
  21. difference = 1234 - 356
  22. print(difference)
  23.  
  24. # increase the salary by 25% => multiply by 1.25
  25. salary = salary * 1.25
  26. salary = int(salary)
  27. print(salary)
  28.  
  29.  
  30. # division with decimals
  31. wind_speed = 25 / 3.6
  32. print(wind_speed)
  33.  
  34. # division without decimals
  35. apples = 25 // 4
  36. print(apples)
  37.  
  38. # how many apples was left over, if 25 is divided by 4?
  39. leftover = 25 % 4
  40. print(leftover)
  41.  
  42. # therefore 4 * 6 = 24, + 1 remainder = 25 apples
  43.  
  44. # this is same as salary = salary + 300
  45. salary += 300
  46. print(salary)
  47.  
  48. # NEW FILE
  49.  
  50. salary = 3000
  51. savings = 2750
  52. debt = 1275
  53.  
  54. total_money = salary + savings - debt
  55. print(total_money)
  56.  
  57. name = "John Doe"
  58.  
  59. # easiest way to combine any kind of variable is to
  60. # use f-strings!
  61. print(f"Hello {name}! Your balance: {total_money} €")
  62.  
  63. # NEW FILE
  64.  
  65. # get integer from user, remember to change the input to int!
  66. # input always gives text at first
  67. number = input("Give a number: ")
  68. number = int(number)
  69.  
  70. # and get a decimal number from user
  71. another = input("Give another number: ")
  72. another = float(another)
  73.  
  74. # print the sum
  75. print(number + another)
Advertisement
Add Comment
Please, Sign In to add comment