
(Python) Создайте игральный кубик. Для каждого из чисел придумайте своё задание, которое дол- жен
выполнить пользователь, который играет в игру; после чего выведите его на экран.

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

Ответ:
print("*Подкидываем игральный кубик*")
from random import randint
var_1 = randint(1,6)
res = 0
if var_1:
if var_1 == 1:
print("Вам выпало число 1!")
print("Сделайте 15 отжиманий.")
if var_1 == 2:
print("Вам выпало число 2!")
print("Сделайте 15 приседаний.")
if var_1 == 3:
print("Вам выпало число 3!")
print("Оббежите вокруг своего дома 1 раз.")
if var_1 == 4:
print("Вам выпало число 4!")
print("Сделайте 30 прыжков.")
if var_1 == 5:
print("Вам выпало число 5!")
print("Покрутите обруч 30 секунд.")
if var_1 == 6:
print("Вам выпало число 6!")
print("Постойте в планке 20-30 секунд.")



Creating a Dice Game in Python
To create a dice game in Python, we can use the `random` module to generate random numbers representing the dice rolls. We can then assign tasks or actions to each number and display them to the user.
Here's an example of how you can create a dice game in Python:
```python import random
# Define the tasks for each number on the dice tasks = { 1: "Do 10 push-ups", 2: "Sing a song", 3: "Tell a joke", 4: "Do a dance", 5: "Name 5 countries", 6: "Do a handstand" }
# Roll the dice dice_roll = random.randint(1, 6)
# Display the task to the user print("You rolled a", dice_roll) print("Task:", tasks[dice_roll]) ```
In this example, we first import the `random` module to generate random numbers. We then define a dictionary called `tasks` where each key represents a number on the dice, and the corresponding value is the task or action associated with that number.
We use the `random.randint(1, 6)` function to simulate rolling a six-sided dice. The result is stored in the variable `dice_roll`.
Finally, we display the dice roll result and the corresponding task to the user.
You can run this code in a Python environment to see the output. Each time you run the code, a random task will be assigned based on the dice roll.
I hope this helps! Let me know if you have any further questions.


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







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