Сделайте игру по типу камень ножницы бумага с другими элементами должно присутствовать 5 элементов (Python)
по схеме ниже
import random
print("Добро пожаловать в игру камень, ножницы, бумага")
print("Ваша задача выиграть компьютер")
print("Для игры у вас доступны команды к - камень, н - ножницы и б - бумага")
player_score = 0
player_select = 0
comp_score = 0
comp_select = 0
print("Да начнется битва!")
for i in range(3):
print("================================")
print(f" ✦ раунд № {i+1} ✦")
print("================================")
comp_select = random.choice("кнб")
while True:
player_select = input("Сделайте свой выбор: ")
if (player_select == "к") or (player_select == "н") or (player_select == "б"):
break
else:
print("Вы неправильно написали букву")
print(f"Компьютер выбрал {comp_select}")
if player_select == comp_select:
print("Ничья!")
elif player_select == "к" and comp_select == "н":
player_score = player_score + 1
print("Вы выбрали ✊ Компьютер ✌")
elif player_select == "н" and comp_select == "б":
player_score = player_score + 1
print("Вы выбрали ✌ Компьютер ")
elif player_select == "б" and comp_select == "к":
player_score = player_score + 1
print("Вы выбрали Компьютер ✊")
elif player_select == "к" and comp_select == "б":
comp_score = comp_score + 1
print("Вы выбрали ✊ Компьютер ")
elif player_select == "н" and comp_select == "к":
comp_score = comp_score + 1
print("Вы выбрали ✌ Компьютер ✊")
elif player_select == "б" and comp_select == "н":
comp_score = comp_score + 1
print("Вы выбрали Компьютер ✌")
print("============================")
print(" Результаты игры")
print("============================")
if player_score > player_socre:
print("Win")
elif player_score < comp_score:
print("✱ ✱ lose! ✱ ✱")
else:
print("Ничья")
Ответы
Ответ:
import random
your_score = 0
comp_score = 0
while True:
you = input("Выберите камень / ножницы / бумага")
If you == 'камень' or you == 'ножницы' or you == 'бумага':
comp = random.randint(1, 3)
if comp == 1:
comp = 'камень'
elif comp == 2:
comp = 'ножницы'
else:
comp = 'бумага'
print("Камень, ножницы, бумага")
print('1')
print('2')
print('3')
print("Компьютер выбрал", comp)
if comp == you:
print("Ничья")
elif you == 'камень' and comp == 'ножницы':
print("Вы победили")
your_score += 1
elif you == 'ножницы' and comp == 'бумага':
print("Вы победили")
your_score += 1
elif you == 'бумага' and comp == 'камень':
print("Вы победили")
your_score += 1
else:
print("Вы проиграли")
comp_score += 1
print("Счет: ты:", your_score, "компьютер:", comp_score)
else:
print("такого варианта нет")