Advertisement
ssoni

haircut.py

May 10th, 2024
813
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.69 KB | None | 0 0
  1. import random
  2.  
  3. def main():
  4.     price = 25
  5.     inflation = 3
  6.     ror = 8
  7.     total=0
  8.     FREQ = 12
  9.     AGE = 17
  10.     END_AGE = 65
  11.     x=0
  12.  
  13.     for i in range(END_AGE - AGE):
  14.         haircutCostPerYear = price*FREQ
  15.         total = total + haircutCostPerYear
  16.         total = total *(1+ror/100)
  17.         price = price * (1+inflation/100)        
  18.     print(f'Total saved is {total}')
  19.    
  20.     d=1
  21.     while(total > 0):
  22.         total = gamble(total)
  23.         print(f'After {d} drunken casino night, Total saved is {total}')
  24.         d += 1
  25.  
  26. def gamble(total):
  27.     num = random.randint(1,2)
  28.     if num==1:
  29.         total = total * 2
  30.     else:
  31.         total = 0
  32.     return total
  33.  
  34. main()
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement