
ПОМОГИТЕ ПОЖАЛУЙСТА НАПИСАТЬ ПРОГРАММУ НА PYTHON!!! Алиса играет в пинг-понг с папой Антоном.
Победит тот, кто первым наберёт 11 очков. Их домашний робот Локи следит за игрой, начисляет очки и записывает — каждый раз в новой строке — имя того, кто получил очко: «Антон» или «Алиса».От волнения Локи перегрелся, и его программа стала работать странно. Локи может следить за счётом и писать имена, но не понимает, когда нужно закончить.Напиши новую программу, которая:1) последовательно прочитает строки, в каждой из которых написано «Алиса» или «Антон». Сколько строк — неизвестно, но мы знаем, что минимум одна партия закончилась победой (в такой игре не может быть ничьей);2) выведет имя того, кто выиграл первую партию, и счёт.Например, так:Алиса11 5

Ответы на вопрос

Ответ:
alice = 0
anton = 0
while alice != 11 and anton != 11:
gamer = input()
if gamer == 'Алиса':
alice += 1
elif gamer == 'Антон':
anton += 1
if alice > anton:
print('Алиса')
print(alice,anton)
else:
print('Антон')
print(anton,alice)
Объяснение:



Writing a Python Program for the Ping-Pong Game
To solve this problem, we can write a Python program that reads the input lines, keeps track of the score, and determines the winner of the game. We'll use a simple algorithm to achieve this.
Here's a Python program that accomplishes the task:
```python # Initialize variables to keep track of the score for each player alice_score = 0 anton_score = 0
# Read the input lines until the end of input while True: try: # Read the next line of input line = input() # Update the score based on the player's name in the input line if "Алиса" in line: alice_score += 1 elif "Антон" in line: anton_score += 1 else: # If the input line doesn't contain a valid player name, skip to the next line continue # Check if either player has reached a score of 11 if alice_score == 11: print("Алиса", alice_score, anton_score) break elif anton_score == 11: print("Антон", anton_score, alice_score) break except EOFError: break ```
This program reads the input lines, updates the scores for each player, and checks if either player has reached a score of 11. Once a player reaches 11 points, the program prints the winner's name and the final score.
You can run this program in a Python environment to see the output based on the input provided.
I hope this helps! Let me know if you have further questions or need additional assistance.


Похожие вопросы
Топ вопросов за вчера в категории Информатика
Последние заданные вопросы в категории Информатика
-
Математика
-
Литература
-
Алгебра
-
Русский язык
-
Геометрия
-
Английский язык
-
Химия
-
Физика
-
Биология
-
Другие предметы
-
История
-
Обществознание
-
Окружающий мир
-
География
-
Українська мова
-
Информатика
-
Українська література
-
Қазақ тiлi
-
Экономика
-
Музыка
-
Право
-
Беларуская мова
-
Французский язык
-
Немецкий язык
-
МХК
-
ОБЖ
-
Психология
-
Физкультура и спорт
-
Астрономия
-
Кыргыз тили
-
Оʻzbek tili