+ 1
Could you explain me how to calculated pls ( for loop )
a=1;b=1 for i in range(9): a,b=b,a+b print(b/a) results 2.0 1.5 1.6666666666666667 1.6 1.625 1.6153846153846154 1.619047619047619 1.6176470588235294 1.6181818181818182 I would like to know how to calculated
3 Antworten
+ 4
when the loop runs first a=1 and b=2
2/1=2.0
When loop runs second time
a=2 and b=3
3/2=1.5
Third time a=3 and b=2+3=5
5/3 =1.6666
And so on
+ 6
May be you can tell us what you want to achieve? Please make samples and give us input values, and how your output should be. Thanks!
+ 2
okay thank you for the answers !
at first when I saw the question
I thought that should be like (a),(b=b),(a+b)
so that made me confuse, it should be like this (a,b)=(b,a+b)