Question: In this homework, you are supposed to create a mini game where the player is stuck on a magical island. The only way to get

In this homework, you are supposed to create a mini game where the player is stuck on a magical
island. The only way to get out of the island is to beat the wild monster!
Write a python program which has two functions:
perform_attack: This function calculates the health points (hp) of the player and the
monster after they attack each other. Every attack causes a random hp loss between
[10-20] on them. The function takes the players and monsters current hp as
parameters and returns the resulting hp of the user and monster after the damage in
that round.
battle: This function first randomly generates the players and the monsters initial hp
between [50-100]. Then, they start attacking each other until one of them beats the
other (i.e. when hp<=0). The function prints their hp respectively in each round calling
the perform_attack function. At the end, it prints the winner.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!