Every week a vampire has to bite a human and turns them into another vampire. Th
ID: 3743957 • Letter: E
Question
Every week a vampire has to bite a human and turns them into another vampire. Therefore, the number of vampires after each week doubles. ( If we start out with 1 vampire, after a week we have 2 vampires, after another week we have 4 vampires, then 8, etc.
1) Ask the user for how many weeks they want to run the simulation for and then output the vampire population at the end.
How many weeks? :
4
The earth has 16 vampires after 4 weeks.
2) If the number of vampires is greater than the number of humans then stop your loop. The final output will show that there are no humans left and how many weeks it took to wipe us out.
How many weeks? :
200
The human population was destroyed after just *x* weeks.
Explanation / Answer
from math import *
humans = 7500000000
print("How many weeks? : ")
weeks = input()
vampires = pow(2,weeks)
if(vampires >= humans):
print 'The human population was destroyed after just ',weeks,' weeks.'
else:
print 'The earth has ',vampires,' vampires after ',weeks,' weeks.'
Output:
How many weeks? :
The earth has 16 vampires after 4 weeks.
Do ask if any doubt. Please upvote.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.