
Вы пришли на работу в контору по разработке игр, целевая аудитория — дети и их родители. У прошлого
программиста было задание сделать две игры в одном приложении, чтобы пользователь мог выбирать одну из них. Однако программист, на место которого вы пришли, перед увольнением не успел сделать эту задачу и оставил только небольшой шаблон проекта. Используя этот шаблон, реализуйте игры «Камень, ножницы, бумага» и «Угадай число». Правила игры «Камень, ножницы, бумага»: программа запрашивает у пользователя строку и выводит, победил он или проиграл. Камень бьёт ножницы, ножницы режут бумагу, бумага кроет камень. Правила игры «Угадай число»: программа запрашивает у пользователя число до тех пор, пока он его не отгадает. def rock_paper_scissors(): # Здесь будет игра "Камень, ножницы, бумага" def guess_the_number(): # Здесь будет игра "Угадай число" def mainMenu(): # Здесь главное меню игры mainMenu(): pass

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

Решение:
Python
#Камень, ножницы, бумага
import random
def rock_paper_scissors():
player = input('камень, ножницы или бумага? ')
game = ['камень', 'ножницы', 'бумага']
game = game[random.randint(0, 2)]
print(game)
if player == 'камень':
if game == 'камень':
print('ничья')
elif game == 'ножницы':
print('камень бьет ножницы')
else:
print('бумага бьет камень')
elif player == 'ножницы':
if game == 'камень':
print('камень бьет ножницы')
elif game == 'ножницы':
print('ничья')
else:
print('ножницы бьют бумагу')
else:
if game == 'камень':
print('бумага бьет камень')
elif game == 'ножницы':
print('ножницы бьют бумагу')
else:
print('ничья')
#Угадай число
def guess_the_number():
randomItem = int(str(random.random())[2:(random.randint(3, 9))])
print(randomItem)
while True:
inputItem = input('Введите число: ')
if inputItem == randomItem:
break
if inputItem == 'подсказка':
print(f'Длина числа {len(str(randomItem))}')
print('Молодец, ты отгадал число!')
#Меню
def mainMenu():
choise = input('Сыграем в камень, ножницы, бумагу или угадай число? [1 - первое, 2 - второе]: ')
if choise == '1':
rock_paper_scissors()
else:
guess_the_number()
mainMenu()



Introduction
As a game development company targeting children and their parents, you have been tasked with implementing two games, "Rock, Paper, Scissors" and "Guess the Number," in a single application. The previous programmer left behind a project template, and you will use it to complete the task.
Rules of the Game: Rock, Paper, Scissors
In the game "Rock, Paper, Scissors," the program prompts the user for input and determines whether they won or lost. The rules are as follows: - Rock beats scissors. - Scissors cut paper. - Paper covers rock.
To implement this game, you can use the following code template: ```python def rock_paper_scissors(): # Here will be the implementation of the "Rock, Paper, Scissors" game ```
Rules of the Game: Guess the Number
In the game "Guess the Number," the program prompts the user to guess a number until they guess it correctly. The implementation can be as follows: ```python def guess_the_number(): # Here will be the implementation of the "Guess the Number" game ```
Main Menu
To create a main menu for the game, you can use the following code template: ```python def mainMenu(): # Here will be the main menu of the game pass ```
By combining these code templates and implementing the game logic within each function, you can create an application that allows the user to choose between playing "Rock, Paper, Scissors" or "Guess the Number" from the main menu.
Remember to fill in the implementation details for each game within the respective function templates.
I hope this helps you get started on developing the games! Let me know if you have any further questions.


Похожие вопросы
Топ вопросов за вчера в категории Информатика







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