Advertisement
Spocoman

02. Sleepy Tom Cat

Dec 18th, 2021 (edited)
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. day = int(input())
  2. workday = (365 - day) * 63
  3. holiday = day * 127
  4. total = workday + holiday
  5. diff = abs(total - 30000)
  6.  
  7. if total >= 30000:  
  8.     print('Tom will run away')
  9.     print(f'{diff // 60} hours and {diff % 60} minutes more for play')
  10. else:
  11.     print('Tom sleeps well')
  12.     print(f'{diff // 60} hours and {diff % 60} minutes less for play')
  13.  
  14.  
  15. Решение с тернарен оператор:
  16.  
  17. day = int(input())
  18. total = ((365 - day) * 63 + day * 127) - 30000
  19.  
  20. print('Tom will run away' if total >= 0 else 'Tom sleeps well')
  21. print(f'{abs(total) // 60} hours and {abs(total) % 60} minutes {"more" if total >= 0 else "less"} for play')
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement