Advertisement
Spocoman

Vet Parking

Feb 16th, 2022 (edited)
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.83 KB | None | 0 0
  1. day = int(input())
  2. hour = int(input())
  3. total = 0
  4.  
  5. for i in range(1, day + 1):
  6.     sums = 0
  7.     for j in range(1, hour + 1):
  8.         if i % 2 == 1:
  9.             if j % 2 == 1:
  10.                 sums += 1
  11.             else:
  12.                 sums += 1.25
  13.         else:
  14.             if j % 2 == 1:
  15.                 sums += 2.5
  16.             else:
  17.                 sums += 1
  18.  
  19.     print(f"Day: {i} - {sums:.2f} leva")
  20.     total += sums
  21.  
  22. print(f"Total: {total:.2f} leva")
  23.  
  24. РЕШЕНИЕ С ТЕРНАРЕН ОПЕРАТОР:
  25.  
  26. day = int(input())
  27. hour = int(input())
  28. total = 0
  29.  
  30. for i in range(1, day + 1):
  31.     sums = 0
  32.     for j in range(1, hour + 1):
  33.         sums += (1 if j % 2 == 1 else 1.25) if i % 2 == 1 else (2.5 if j % 2 == 1 else 1)
  34.     print(f"Day: {i} - {sums:.2f} leva")
  35.     total += sums
  36.  
  37. print(f"Total: {total:.2f} leva")
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement