Advertisement
Spocoman

Care of Puppy

Jan 6th, 2022 (edited)
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.02 KB | None | 0 0
  1. food = int(input()) * 1000
  2. total = 0
  3.  
  4. command = input()
  5. while command != 'Adopted':
  6.     day_food = int(command)
  7.     total += day_food
  8.     command = input()
  9.    
  10. if food >= total:
  11.     print(f'Food is enough! Leftovers: {food - total} grams.')
  12. else:
  13.     print(f'Food is not enough. You need {total - food} grams more.')
  14.  
  15. ИЛИ С ПРИСПАДАНЕ ОТ ДАДЕНОТО КОЛИЧЕСТВО ХРАНА:
  16.  
  17. food = int(input()) * 1000
  18.  
  19. command = input()
  20. while command != 'Adopted':
  21.     food -= int(command)
  22.     command = input()
  23.  
  24. if food >= 0:
  25.     print(f'Food is enough! Leftovers: {food} grams.')
  26. else:
  27.     print(f'Food is not enough. You need {abs(food)} grams more.')
  28.    
  29. ДРУГО РЕШЕНИЕ С ТЕРНАРЕН ОПЕРАТОР:
  30.  
  31. food = int(input()) * 1000
  32.  
  33. while True:
  34.     command = input()
  35.     if command == 'Adopted':
  36.         break
  37.     food -= int(command)
  38.  
  39. print(f'Food is enough! Leftovers: {food} grams.' if food >= 0 else
  40.       f'Food is not enough. You need {abs(food)} grams more.')
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement