Advertisement
Guest User

task5

a guest
Mar 29th, 2020
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.94 KB | None | 0 0
  1. class Music():
  2.     name = ''
  3.     duration = ''
  4.     number = ''
  5.  
  6. def add():
  7.     composition = Music()
  8.     composition.name = input("Введите название песни: ")
  9.     composition.duration = input("Введите продолжительность песни: ")
  10.     composition.number = int(input("Введите порядковый номер песни в плей-листе: "))
  11.     return(composition)
  12.  
  13. playlist = []
  14.  
  15. for i in range(3):
  16.     playlist.append(add())
  17.  
  18. n = int(input("Какая песня сейчас играет?"))
  19.  
  20. if n == playlist[2].number:
  21.     print("Сейчас играет последняя песня: " + playlist[2].name + " " + playlist[2].duration)
  22. elif n == playlist[1].number:
  23.     print("Сейчас играет песня: " + playlist[1].name + " " + playlist[1].duration)
  24. else:
  25.     print("Сейчас играет песня: " + playlist[0].name + " " + playlist[0].duration)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement