exponential functions · MIT License
Overview
Solve compound and continuous interest problems: find the final amount, compare two rates, find the starting amount, or find the time needed.
- Owner-tested on a TI calculator
- Version 1.0.0
- 1551 bytes
- Uses math
Before you run it
- TI-84 Plus CE Python · No calculator OS or Python App version has been verified.
- TI Connect CE .py transfer to the Python App; the owner's transfer details were not recorded
- Interest follows A = P(1+r/n)^(nt), or A = Pe^(rt) when n is 0.
- The rate and compounding stay the same for the whole period.
- n cannot be negative; the program asks again until it is 0 or more.
Try the DuckieDai calculator screen
Follow the program's prompts and result flow before downloading.
TI-84 Plus CE Python · screen preview
Learn the maths
What compound interest is
The idea
Compound interest is interest that earns interest. Each time interest is added, it joins the balance, and the next round of interest is worked out on the new, larger balance. Simple interest, by comparison, is only ever worked out on the amount you started with.
Example: $1,000 at 5% a year for 10 years grows to $1,500.00 with simple interest, and to $1,628.89 when the interest is compounded once a year.
The formula
A = P(1 + r/n)^(nt)
A- the final amount
P- the starting amount, also called the principal
r- the yearly interest rate as a decimal, so 5% is 0.05
n- how many times a year interest is added
t- the time in years
When interest is added continuously, the formula becomes:
A = Pe^(rt)
Common values of n: yearly 1, semiannual 2, quarterly 4, monthly 12, weekly 52, daily 365. In this program, type 0 for continuous.
What each menu choice does
- 1: Find amount A. Enter P, the rate, n, and the years to get the final amount and the interest earned.
- 2: Compare 2 rates. Enter P and the years once, then two rate and n options, to see which one ends larger and by how much.
- 3: Find start P. Enter the amount you want to end with to get the amount you need to start with.
- 4: Find time t. Enter P and A to get how many years the growth takes.
- 5: n values help. Shows the list of n values on the calculator.
- 6: Quit.
Type the rate as a percent: 5 means 5%. Any number can also be typed as a fraction, such as 1/2 for half a year.
Worked examples
Find the amount: $1,000 at 5%, compounded monthly, for 10 years. Choose 1 and enter P = 1000, rate = 5, n = 12, years = 10.
A = 1000(1 + 0.05/12)^(12*10) = $1647.01
The program shows A = $1647.01 and Interest = $647.01. With n = 0 (continuous) the same inputs give A = $1648.72.
Find the time: how long does $1,000 take to reach $2,000 at 6%, compounded monthly? Choose 4 and enter P = 1000, A = 2000, rate = 6, n = 12. The program shows t = 11.5813 years.
Exact reviewed bytes
Source code
from math import exp,logdef P(s=""):input(s+"\nPress enter ")print("\n"*7)def N(p):while 1:s=input(p)try:if "/" in s:u,v=s.split("/")return float(u)/float(v)return float(s)except Exception:print("Enter a number.")def R():r=N("rate %? ")/100n=-1while n<0:n=N("n/yr (0=cont)? ")return r,ndef G(r,n,t):if n:return (1+r/n)**(n*t)return exp(r*t)def M(v):return "$"+str(round(v,2))def S(r,n):if n:return "A=P(1+r/n)^(nt)"return "A=Pe^(rt)"print(" Interest\n __\n ___(o )> quack!\n \\ <_. )\n `---'\n by DuckieDai\nhiddenwordscanner.com")P()c=""while c!="6":print("1:Find amount A\n2:Compare 2 rates\n3:Find start P\n4:Find time t\n5:n values help\n6:Quit")c=input("Choice? ")print("\n"*7)if c=="1":p=N("P? ")r,n=R()t=N("years? ")a=p*G(r,n,t)P(S(r,n)+"\nA = "+M(a)+"\nInterest = "+M(a-p))elif c=="2":p=N("P? ")t=N("years? ")print("OPTION 1")r,n=R()a=p*G(r,n,t)print("OPTION 2")r,n=R()b=p*G(r,n,t)print("\n1: "+M(a)+"\n2: "+M(b))if a==b:s="Same amount"else:s="Option "+("1" if a>b else "2")+" is larger\nby "+M(abs(a-b))P(s)elif c=="3":a=N("A? ")r,n=R()t=N("years? ")P("P = "+M(a/G(r,n,t)))elif c=="4":p=N("P? ")a=N("A? ")r,n=R()try:P("t = "+str(round(log(a/p)/log(G(r,n,1)),4))+" years")except Exception:P("No solution.")elif c=="5":P("n = times per year\nyearly 1\nsemiannual 2\nquarterly 4\nmonthly 12\nweekly 52\ndaily 365\ncontinuous 0")print("DuckieDai says:\ndone!")
- Filename
COMINT.py- Size
- 1551 bytes
- SHA-256
b78522422d7313cde07597c14d053d475015d4fed1d42c7522874d48d06b9c81
Usage
Inputs
- One menu choice from 1 to 6
- Starting amount P or final amount A
- Annual rate as a percent
- Compounding periods per year n (0 for continuous)
- Time in years
Outputs
- Final amount A and interest earned, with the formula used
- The larger of two rate options and the difference
- Starting amount P
- Time t in years
Units: Money amounts are shown with a dollar sign and rounded to cents; rates are percents per year; time is in years.
Assumptions and limitations
Assumptions
- Interest follows A = P(1+r/n)^(nt), or A = Pe^(rt) when n is 0.
- The rate and compounding stay the same for the whole period.
Constraints
- n cannot be negative; the program asks again until it is 0 or more.
- Numbers may be typed as decimals or as a fraction such as 1/3.
Known failures
- Find time reports No solution when the rate is 0, or when A and P do not allow a real answer.
- Extremely large rates or times produce a number too large for the calculator and stop the program with an error.
- A menu choice other than 1 to 6 shows the menu again.
Compatibility and review
- Review status
- Owner-tested on a TI calculator
- Tested on
- Owner reports personally using this program on a TI-84 Plus CE Python calculator for coursework; the test date, OS version, and Python App version were not recorded
- What happened
- Owner reported pass on the calculator. Only the line endings were normalised for publication; the program text is unchanged. This exact file has not yet been rerun on a calculator.
- Dependencies
- math
- Suggested calculator name
COMINT— you can give it another valid, unique name when you transfer it- Desktop test cases
- Not available for this interactive-only source
This exact source auto-launches an interactive calculator session, so compatibility evidence comes from the recorded physical-device review rather than an importable desktop fixture.
Transfer and launch
- Confirm that your calculator is the Python-capable model named above. This release has no verified calculator OS or Python App version; treat transfer and execution as unverified until independently tested.
- Download the
.pysource above and verify its SHA-256 digest if your computer provides that option. - Use TI Connect CE to send the Python file to a compatible calculator.
COMINTis a suggested name; you may choose another valid, unique calculator name. - Open the Python App, select the program, and check sample inputs before relying on other results.
Read the complete installation, launch, troubleshooting, and removal guide.
Availability does not mean a teacher, school, or exam permits this program. Follow the applicable rules.
Version history
- 1.0.0 — current version, published . Download this reviewed version
Any source change requires a new immutable version and digest. Historical downloads remain available only while their review records remain valid.
Related learning
Independent compatibility resource: Hidden Word Scanner is independent and is not affiliated with or endorsed by Texas Instruments. TI product names describe compatibility only.
Action-count privacy: Successful downloads, preview starts, and preview completions increment same-origin aggregate counters. No entered values, source text, IP address, account, cookie, device identifier, or fingerprint is stored with these counts.