SHARE
TWEET

Untitled

a guest Sep 23rd, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. initial_slime = 0
  2. generations_of_propogation = 0
  3. starting_slime_value = 0
  4.  
  5.  
  6. def ask_for_initial_amount():
  7.     global initial_slime
  8.     initial_slime = float(input("Initial slime amount (grams)-"))
  9.  
  10.  
  11. ask_for_initial_amount()
  12.  
  13.  
  14. def ask_for_generations_of_propogation():
  15.     global generations_of_propogation
  16.     generations_of_propogation = int(input("Generations of propogation---"))
  17.  
  18.  
  19. ask_for_generations_of_propogation()
  20.  
  21. while initial_slime < 0:
  22.     print("Error")
  23.     ask_for_initial_amount()
  24.  
  25. while generations_of_propogation <= 0:
  26.     print("Error: value must be a positive integer")
  27.     ask_for_generations_of_propogation()
  28.  
  29. slime_amount = initial_slime
  30.  
  31. if generations_of_propogation > 0:
  32.     for number in range(0, generations_of_propogation):
  33.         total_slime = starting_slime_value + slime_amount
  34.         starting_slime_value = slime_amount
  35.         slime_amount = total_slime
  36. elif generations_of_propogation == 1:
  37.     total_slime = initial_slime
  38.  
  39. print("")
  40. print("Final slime amount (grams)--- %7.3f" % slime_amount)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top