1
當我運行下面的程序時,它輸出所有的數字爲0.0。如何解決這個問題來說明混沌行爲?如何編寫說明混沌行爲的Python程序
# A simple program illustrating chaotic behaviour
def main():
print ("This program illustrates a chaotic function")
x = int (float(input("Enter a number between 0 and 1: ")))
for i in range(10):
x = 3.9 * x * (1-x)
print (x)
main()
Python的'int()'層數,所以0到1之間的每個數字都舍入爲0。 – wrkyle