Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Repeating equations
#1
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 x
And 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.73828125
and 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!
Quote
#2
Huh? Huh Think

Ok
Use a for loop with a range of 100
  • put the equation inside the loop and then the following also in the loop
  • print x
  • assign s to the value of x
Quote
#3
#!/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)

Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  First non-repeating char and some errors. blackknite 1 297 Jan-06-2019, 02:19 PM
Last Post: stullis
  repeating for loop Kaldesyvon 5 593 Dec-06-2018, 08:00 PM
Last Post: ichabod801
  Repeating same number in sequence Rudinirudini 6 737 Oct-28-2018, 07:44 PM
Last Post: DeaD_EyE
  Python2.7 xrange for loops - repeating though values already considered? nick5990 3 788 Mar-17-2018, 12:42 AM
Last Post: Larz60+
  Stack problem, repeating results that i dont want YapYL 1 777 Dec-10-2017, 04:14 PM
Last Post: hshivaraj
  Repeating a block of code owdcoder 8 2,158 Jul-14-2017, 03:37 PM
Last Post: nilamo

Forum Jump:


Users browsing this thread: 1 Guest(s)