Advertisement
chris_ton

While Loop Exercise - Cake

May 19th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. width = int(input())
  2. length = int(input())
  3.  
  4. cake_area = width * length
  5. all_pieces = 0
  6.  
  7. while cake_area > all_pieces:
  8. pieces = input()
  9. if pieces == "STOP":
  10. pieces_left = cake_area - all_pieces
  11. print(f"{pieces_left} pieces are left.")
  12. break
  13. else:
  14. all_pieces += int(pieces)
  15. if cake_area - int(all_pieces) <= 0:
  16. print(f"No more cake left! You need {abs(cake_area - int(all_pieces))} pieces more.")
  17. else:
  18. continue
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement