私はPython(および一般的なプログラミング)にまったく慣れていないため、Pythonプログラミングの例に従っています:コンピューターサイエンスの紹介John M. Zelle、Ph.D. バージョン 1.0rc2 Fall 2002 明らかに、これはかなり古くなっています。私は Python 3.3 を使用しています。本に示されているとおりに (print ステートメントの周りに () を追加して) 演習を入力していますが、エラーが発生し続けています。これは、私が入力した内容と、プログラムを実行しようとしたときの結果のコピーです。私は何を間違っていますか?
>>> def main():
print ("This program illustrates a chaotic function.")
x=input ("Enter a number between 0 and 1:")
for i in range(10):
x= 3.9*x*(1-x)
print (x)
>>> main()
This program illustrates a chaotic function.
Enter a number between 0 and 1:1
Traceback (most recent call last):
File "<pyshell#12>", line 1, in <module>
main()
File "<pyshell#11>", line 5, in main
x= 3.9*x*(1-x)
TypeError: can't multiply sequence by non-int of type 'float'
>>>