Spocoman

06. Building (solutions with or not ternary operator)

Dec 30th, 2021 (edited)
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. floors = int(input())
  2. flats_per_floor = int(input())
  3.  
  4. for f in range(floors, 0, -1):
  5.     appendix = ""
  6.     if f == floors:
  7.         appendix = "L"
  8.     elif f % 2 == 1:
  9.         appendix = "A"
  10.     else:
  11.         appendix = "O"
  12.     for n in range(flats_per_floor):
  13.         print(f"{appendix}{f}{n}", end=" ")
  14.     print()
  15.  
  16.  
  17. Решение с тернарен оператор:
  18.  
  19. floors = int(input())
  20. flats_per_floor = int(input())
  21.  
  22. for f in range(floors, 0, -1):
  23.     appendix = "L" if f == floors else "A" if f % 2 == 1 else "O"
  24.     for n in range(flats_per_floor):
  25.         print(f"{appendix}{f}{n}", end=" ")
  26.     print()
  27.  
Add Comment
Please, Sign In to add comment