TORONTO KIDS COMPUTER CLUB | Markham Saturday 9:30 Python Homework 11.16.
16730

# Markham Saturday 9:30 Python Homework 11.16.

## 20 Nov Markham Saturday 9:30 Python Homework 11.16.

Question :

You are trying to destroy the enemy spaceship which is protected by the energy shell. However, you only have 2 missiles left. Each missile can cause a random damage between 1 to 150. Assume the enemy’s energy shell can provide 100 protection. Write a program:

• Using random.randint() to calculate each missile’s damage and print them out.
• If the damage of first missile greater than enemy’s protection, print enemy is destroyed after first missile launch
• If the first missile can not destroy the enemy. The protection of the enemy energy shell is deducted by the damage of first missile. And you are going to launch the second missile
• if the second missile’s damage is greater than the protection left over, print enemy is destroyed after second missile launch
• if you did not destroy the enemy after two missiles, print the enemy is escaped.

sample output 1:

missile 1: 59
missile 2: 102
enemy is destroyed after first missile launch

sample output 2:

missile 1: 45
missile 2: 32
the enemy is escaped