![]() |
Repeating equations - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Repeating equations (/thread-18721.html) |
Repeating equations - Tbot100 - May-28-2019 Hello, I am fairly new and have not seen anything in which can help me. I am trying to use this code: s = float(input("Enter starting value from 0 to 1:")) r = float(input("Enter rate:")) x = s*r*(1-s) print xAnd get a result which is correct, but I would like to repeat the formula (s*r*(1-s)) 100 times by making the output, x, s. The output should look something like what is below if s is 0.5 and r is 3: 0.75 0.5625 0.73828125and so on and so forth for another 97 times. If you need me to clarify anything or have a suggestion, I would greatly appreciate it. Thanks! RE: Repeating equations - Yoriz - May-28-2019 Huh? ![]() ![]() Ok Use a for loop with a range of 100
RE: Repeating equations - heiner55 - May-29-2019 #!/usr/bin/python3 s = float(input("Enter starting value from 0 to 1:")) r = float(input("Enter rate:")) for i in range(1000000): s = s*r*(1-s) print(s) |