How do I change my inputs simple and compound with two decimals behind them?

n = 5

rate = 0.05

for n in range(0, 3):

principal = 10000

for n in range (0,6):

    principal <= 15000

    simple = principal *  (1 + rate * n)

    compound = principal * (1 + rate)**n

    ratea = rate * 100

    ratea = int(ratea)

    principal = int(principal)


    print((ratea),"% $",principal," $",simple," $",float(compound))

    principal = principal + 1000

rate = rate + 0.05

Use

print('{0:.2f}% $ {1:.2f} $ {2:.2f} $ {3:.2f}'.format(
    ratea, principal, simple, compound))

see Click Here.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.