Question: PYTHON 3 CODE-------------------------------- John is playing a game and fighting against a monster. The monster attacks n times. Each time the monster attacks, the damage

PYTHON 3 CODE--------------------------------

John is playing a game and fighting against a monster. The monster attacks n times. Each time the monster attacks, the damage is different. The monster dies after all the attacks. john character initially has health h. The first two lines will input h and n respectively. And the following n lines, will input the damage value. We say that the character survived iff it's final health is greater than zero. You need to print if his character will survive by printing True, and printing False otherwise.

Input Format-------------------------

The first line contains h. The second line contains n. Following n lines contain the damage the monster does on each attack

Output Format----------------------

Print True if the character survives, and print False otherwise.

Sample Input ---------------------------

500 4 30 400 10 15

Sample Output ---------------------------

True

Explanation ------------------------

Here, h=500 and n=4. First attack that the monster did causes 30 damage, so current health is 500-30=470. Second attack that the monster did causes 400 damage, so current health is 470-400=70. Third attack that the monster did causes 400 damage, so current health is 70-10=60. Fourth attack that the monster did causes 400 damage, so current health is 60-15=45. As the current health is greater than zero which means that the character survived so we print True

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!