Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Type help
#1
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?
Reply
#2
Print the first value before the loop. In the loop compute c before the print.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020