Advertisement
go6odn28

while_loop_lab_5_6

Oct 6th, 2023
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.64 KB | None | 0 0
  1. While loop-lab
  2.  
  3. # 5 Account Balance:
  4. account_balance = 0
  5.  
  6. while True:
  7.     command = input()
  8.  
  9.     if command == 'NoMoreMoney':
  10.         break
  11.  
  12.     curr_sum = float(command)
  13.  
  14.     if curr_sum >= 0:
  15.         account_balance += curr_sum
  16.         print(f"Increase: {curr_sum:.2f}")
  17.     else:
  18.         print('Invalid operation!')
  19.         break
  20.  
  21. print(f'Total: {account_balance:.2f}')
  22.  
  23.  
  24.  
  25. # 6. Max Number
  26. import sys
  27.  
  28. max_number = - sys.maxsize
  29.  
  30. while True:
  31.     command = input()
  32.     if command == 'Stop':
  33.         break
  34.     curr_num = int(command)
  35.     if curr_num > max_number:
  36.         max_number = curr_num
  37.  
  38. print(max_number)
  39.  
  40.  
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement