Python Forum
Type help - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: Type help (/thread-32917.html)



Type help - aliwien - Mar-16-2021

def sayısal(Vs, Vi):
    return Vs - Vi

def artış(x, r):
    y = x*((r/100)+1)
    return y

h = 1
a = float(input('Number of cases: '))
b = float(input('Percentage increase: '))
c = sayısal(artış(a, b), a)
while a < 30001:
    print(f'{h}) {a} \n +({c})')
    a = artış(a, b)
    h += 1
    c = sayısal(artış(a, b), a)
I wrote this code and it's working but I wanna ask something. Its output is:
1) 10000 (+2500)
2) 12500 (+3125)
3) 15625 (+3096)
...

But ı want like that (for same value):
1) 10000
2) 12500 (+2500)
3) 15625 (+3125)
...
How can I solve that?


RE: Type help - deanhystad - Mar-16-2021

Print the first value before the loop. In the loop compute c before the print.