importsysimportrandomdefzombie_shootout(num_of_zombies,distance,num_of_bullets):'''
Work out if you survive the zombie's assault
'''zombie_speed=0.5num_of_zombies_shot=0probability_of_missing=0.05num_of_zombies_remaining=num_of_zombiesforbulletinrange(num_of_bullets):ifdistance==0:return"You shot {} zombie(s) before being eaten: overwhelmed.".format(num_of_zombies_shot)ifnum_of_zombies_remaining==0:return"You shot all {} zombies.".format(num_of_zombies)distance-=zombie_speedshot_chance=random.randint(0,100)ifshot_chance>=probability_of_missing:num_of_zombies_shot+=1num_of_zombies_remaining-=1return"You shot {} zombie(s) before being eaten: ran out of ammo.".format(num_of_zombies_shot)iflen(sys.argv)>3:print(zombie_shootout(int(sys.argv[1]),int(sys.argv[2]),int(sys.argv[3])))
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
In Python