Skip to content

Instantly share code, notes, and snippets.

@luizguilhermefr
Created January 30, 2020 19:45
Show Gist options
  • Save luizguilhermefr/915252aa8bb6edfc0a46c2bd3d75e9bd to your computer and use it in GitHub Desktop.
Save luizguilhermefr/915252aa8bb6edfc0a46c2bd3d75e9bd to your computer and use it in GitHub Desktop.
Stonks calculator
print("\033[31m STONKS \033[m")
print(35*"=")
print(" ")
initial = float(input("\033[32mINITIAL VALUE\033[m: "))
monthly = float(input("MONTHLY \033[32mAPPLICATION\033[m: "))
rate = float(input("\033[32mMONTHLY\033[m RATE (%): ")) / 100
time = int(input("\033[32mTOTAL\033[m YEARS: ")) * 12
amount = initial
for i in range(1, time + 1):
amount = (amount + monthly) + (amount * rate)
if i % 12 == 0:
print(f"\033[35mYEAR\033[m \033[33m{int(i / 12)}\033[m - - \033[34mTOTAL\033[m: \033[33m{amount:.2f}\033[m")
else:
print(f"\033[31mMONTH\033[m \033[33m{i}\033[m - - \033[34mTOTAL\033[m:\033[33m {amount:.3f}\033[m")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment