Advertisement
desislava_topuzakova

3. Solar System

Apr 16th, 2018
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.45 KB | None | 0 0
  1. planet = input()
  2. days = int(input())
  3. daysThere = 0
  4. allDist = 0
  5. isValid = True
  6. if planet == "Mercury":
  7.     if days > 7:
  8.         print("Invalid number of days!")
  9.         isValid = False
  10.     allDist = 2 * 0.61
  11.     daysThere = (2 * 226 * 0.61) + days
  12. elif planet == "Venus":
  13.     if days > 14:
  14.         print("Invalid number of days!")
  15.         isValid = False
  16.     allDist = 2 * 0.28
  17.     daysThere = (2 * 226 * 0.28) + days
  18. elif planet == "Mars":
  19.     if days > 20:
  20.         print("Invalid number of days!")
  21.         isValid = False
  22.     allDist = 2 * 0.52
  23.     daysThere = (2 * 226 * 0.52) + days
  24. elif planet == "Jupiter":
  25.     if days > 5:
  26.         print("Invalid number of days!")
  27.         isValid = False
  28.     allDist = 2 * 4.2
  29.     daysThere = (2 * 226 * 4.2) + days
  30. elif planet == "Saturn":
  31.     if days > 3:
  32.         print("Invalid number of days!")
  33.         isValid = False
  34.     allDist = 2 * 8.52
  35.     daysThere = (2 * 226 * 8.52) + days
  36. elif planet == "Uranus":
  37.     if days > 3:
  38.         print("Invalid number of days!")
  39.         isValid = False
  40.     allDist = 2 * 18.21
  41.     daysThere = (2 * 226 * 18.21) + days
  42. elif planet == "Neptune":
  43.     if days > 2:
  44.         print("Invalid number of days!")
  45.         isValid = False
  46.     allDist = 2 * 29.09
  47.     daysThere = (2 * 226 * 29.09) + days
  48. else:
  49.     print("Invalid planet name!")
  50.     isValid = False
  51.  
  52. if isValid:
  53.     print("Distance: %.2f" % allDist)
  54.     print("Total number of days: %.2f" % daysThere)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement