Question
PYTHON PROGRAMMING!!! import random as rand from urllib.request import HTTPPasswordMgr rest = 'no' # Loop runs as long as the adventurer doesn't want to rest
PYTHON PROGRAMMING!!!
import random as rand
from urllib.request import HTTPPasswordMgr
rest = 'no'
# Loop runs as long as the adventurer doesn't want to rest
while rest == 'no':
actual = -99 # Value of the actual Sphinx number
health = 0 # Adventurer health bar
beast_health = 50 # Sphinx health bar
# 5. Ask the user to guess the Sphinx's number in the following way:
# 'Adventurer... if you can guess my number between 1 and 5 you can pass without any trouble. What is your guess?'
# Store the result in the variable guess.
# Generate a random number between 1 and 5 and store the result in the variable actual.
if guess == actual: # Executes if the user's guess is the same as the Sphinx's number
print('SUCCESS! PASS WITH CARE AND YOUR LIFE...')
else: # Executes if the user's guess is not the same as the Sphinx's number
print('INCORRECT! PREPARE TO FIGHT!')
hits = 0 # Represents the number of hits the beast takes
while beast_health > 0: # Runs while the beast is still alive
# 7. Inside the while loop for the fight:
# If the weapon carried is a sword, generate a random number between 16 and 20 for an attack value.
# Store this attack in a variable called my_attack.
# Otherwise, generate a random number between 10 and 15.
# Store this attack in a variable called my_attack.
# 8. Calculate the new health for the beast by subtracting my_attack from beast_health.
# Increase the value of the variable hits by 1.
# 9. If the beast's health is less than or equal to 0, print
# 'You hit for ' (damage dealt) ' and beast is dead in ' (# hits) ' hits!'
# {Otherwise, print
# 'You hit for ' (damage dealt) ' and beast health drops to ' (beast health)
# Generate an attack value for the beast attack between 0 and 10 and store in a variable called beast_attack
# Calculate your new health value by subtracting beast_attack from health.
# Print 'Beast hits for ' (beast attack) ' and your health drops to ' (health)}
# 10. Construct a while loop that gets the user to enter yes or no and keeps running until they do.
# 'The day comes to an end... Will you rest, yes or no?'
# Store the user input in the variable rest.
# If the user enters yes, print 'A well-earned rest.'
rest = ''
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started