Question: Fill in and complete the following Python file and follow the directions within it. It will have you build a Bot Army using classes: *Indents

Fill in and complete the following Python file and follow the directions within it. It will have you build a "Bot Army" using classes:

*Indents would not paste properly in the code below*

-----------------------------------------------------------------------

Below you will find some code that you are to complete. The code is to be

used

to build a "Bot Army". Each of the bots will be assigned a 'botId' and

will

recieve a random helathScore between 0 and 100 when each bot is

instantiated. The bots will be

created using the Bot class.

The Bot class also has a setHealth method that is used to generate a

random number

between -100 and 100 which is then added to the healthScore for the bot.

The main function will create the botArmy list, and then generate

healthScores for each

bot 100 times. You will need to use a nested list for this.

You are then to loop through the botArmy list and call the setHealth

method of the

Bot class.

Then loop through the botArmy and if the healthScore property is less than

zero,

then create a new property named "dead" and assign it the value True.

Else, set

it to False.

Lastly, print out each bot's Id, healthScore, and the value of the dead

property.

"""

# import random library

# Your code goes here

# create Bot class

class Bot:

# when new Bots get created

# the playerId gets passed in

def __init__(self,botId):

# set id to the playerId

# Your code goes here

# set healthScore to a random number between 0 and 100

# setHealth method

def setHealth(self):

# generates a random health score between -100 and 100

# Your code goes here

# add the exisiting healthScore to the newly generated score

# Your code goes here

# set the healthScore to this new score

# Your code goes here

# main function

def main():

# create botArmy list

# Your code goes here

# Create a bot army with 100 bots and add to botArmy list

# Your code goes here

# create nested loops to set the health 100 times

# Your code goes here

# Loop through the botArmy

# Your code goes here

# If health score < 0 then set the dead property to True. If it is

above 0

# then set dead to False

# Your code goes here

# Display the bot army, the healthScore and dead properties

# Your code goes here

# begin the program

main()

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!