Advertisement
Guest User

edited

a guest
Feb 16th, 2020
855
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.06 KB | None | 0 0
  1. cake_width = int(input())
  2. cake_length = int(input())
  3. cake = cake_length * cake_width
  4. # pieces_count = int(input()) - ??
  5. pieces_count = 0  # почваш от 0 и ги броиш в цикъла на ред 13/14
  6. # pieces = pieces_count * 1 - излишно умножаваш по 1 в друга променлива и винаги ще ти даде същото число
  7. while cake > pieces_count:
  8.     command = input()
  9.  
  10.     if command == "STOP":
  11.         break
  12.  
  13.     add = int(command)  # тези два реда могат да се направят директно на един - pieces_count += int(command)
  14.     pieces_count += add  # но трябва да са след цикъла, за да се стига до тях само ако командата не е STOP
  15.  
  16. pieces_display = abs(cake - pieces_count)  # трябва да е след цикъла, за да прави изчисление
  17.  
  18. if cake > pieces_count:
  19.     print(f"{pieces_display} pieces are left.")
  20. else:
  21.     print(f"No more cake left! You need {pieces_display} pieces more.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement