Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database And Transact SQL

Authors: Lucy Scott

1st Edition

1974679985, 978-1974679980

More Books

Students also viewed these Databases questions

Question

4. How has e-commerce affected business-to-business transactions?

Answered: 1 week ago