1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Sidana [21]
3 years ago
9

Create a while loop to try making a video game turn based battle.

Computers and Technology
1 answer:
elena-14-01-66 [18.8K]3 years ago
5 0

import random

monster_health = 20

player_health = 20

while player_health >0 and monster_health>0:

   player_choice = input("Do you wish to attack, heal, or do magic? (type attack, heal, or magic) ")

   if player_choice == "attack":

       damage = random.randint(1,6)

       monster_health -= damage

       print("You attack the monster for",damage,"points of health. The monster has",monster_health,"points of health")

   elif player_choice == "heal":

       heal = random.randint(1,6)

       player_health += heal

       if player_health>20:

           player_health = 20

       print("You heal for",heal,"points of health. Your health is now at",player_health)

   elif player_choice == "magic":

       total = 0

       for x in range(2):

           total += random.randint(1,6)

       monster_health -= total

       print("You attack the monster for",total,"points of health. The monster has",monster_health,"points of health")

   if player_health < 1 or monster_health <1:

       break

   monster_damage = random.randint(1,6)

   player_health -= monster_damage

   print("The monster attacks your for",monster_damage,"points of health. You have",player_health,"points of health remaining.")

if player_health < 1:

   print("You died! Better luck next time!")

elif monster_health < 1:

   print("You defeated the monster! Great job!")

I wrote my code in python 3.8. Best of luck.

You might be interested in
Which tab should you click if you want to access the Show All Comments option in a worksheet?
Lostsunrise [7]

Answer: Review

Because you want to review the comments

3 0
3 years ago
Read 2 more answers
If you were going to construct a table that only included shape names with number prefixes, which shape would you include
NikAS [45]
The answer would be A. square
3 0
4 years ago
97. How many bits is a ki obyte?<br> a. 1000<br> b. 1024<br> c. 8192<br> d. 8124<br> 5
Basile [38]

Answer:

b

1024

is the correct answer

6 0
3 years ago
Read 2 more answers
The idea that the number of transistors on integrated circuits doubles approximately every two years is known as Moore's Law.
igor_vitrenko [27]
False<-------------------
7 0
4 years ago
It's not possible to die in an alcohol-related collision if you're not in an automobile.
frutty [35]

Answer:

B. False

Explanation:

  • Consumption of alcohol is not a good practice and is generally not allowed at the time of driving an automobile and is considered to be an offense as it may be injurious to health and property.
  • As too much alcohol can create possible chances of collusions and even if the person is not in an automobile can result in a collision if tries to cross the road. Like head injuries or leg injuries can occur.
8 0
3 years ago
Other questions:
  • The most widely used presentation software program is Microsoft PowerPoint. You can produce a professional and memorable present
    15·1 answer
  • Clicking on this will minimize all open windows.
    5·2 answers
  • What is the first thing you should do when creating a spreadsheet
    5·1 answer
  • An automated search feature used by search engines to find results that match your search terms is called a spider or ?
    5·1 answer
  • Anyone got the edmentum computer programming post test answers?
    6·1 answer
  • A new systems development project is Pete’s first experience as a project manager, and he has led his team successfully to the p
    13·1 answer
  • How many different textile items would you find at a festival? (please list 5 items)
    7·1 answer
  • Is it safe for me to use normal glue to stick things on my laptop like stickers or pics?
    12·2 answers
  • What refers to a set of instructions executed in order?
    6·1 answer
  • A database admin uses a SHOW statement to retrieve information about objects in a database. This information is contained in a _
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!