Advertisement
SimeonTs

SUPyF Exam Preparation 2 - 01. Date_Estimation

Aug 16th, 2019
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.12 KB | None | 0 0
  1. """
  2. Basics OOP Principles
  3. Check your solution: https://judge.softuni.bg/Contests/Practice/Index/1578#0
  4.  
  5. SUPyF Exam Preparation 2 - 01. Date_Estimation
  6.  
  7. Problem:
  8. Today is your exam. It’s 26th of August 2018. you will be given a single date in format year-month-day.
  9. You should estimate if the date has passed regarding to the date mention above (2018-08-26),
  10. if it is not or if it is today. If it is not you should print how many days are left till that date.
  11. Note that the current day stills count!
  12. Date Format:
  13. yyyy-mm-dd
  14. Output
  15. The output should be printed on the console.
  16. If the date has passed you should print the following output:
  17. • "Passed"
  18. If the day is today:
  19. "Today date"
  20. If the date is future:
  21. • "{number of days} days"
  22. Examples:
  23. Input:
  24. 2018-08-20
  25. Output:
  26. Passed
  27.  
  28. Input:
  29. 2021-08-26
  30. Output:
  31. 1097 days left
  32. """
  33.  
  34. from datetime import date
  35. year, month, day = (int(item) for item in input().split("-"))
  36. delta = date(2018, 8, 26) - date(year, month, day)
  37.  
  38. if delta.days == 0:
  39.     print("Today date")
  40. elif delta.days > 0:
  41.     print("Passed")
  42. else:
  43.     print(f"{abs(delta.days) + 1} days left")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement