Python Programmingを読む

Python Programming: An Introduction to Computer Science

Python Programming: An Introduction to Computer Science

コンピュータで(簡単な)数値計算をする方法を解説した本。
最初の部分を読む限り、内容は大学初年度レベルらしい。

  • 1.6節:The Magic of Python
    • 例題プログラムがロジスティック写像の計算(chaotic.py)。先月、ロジスティック写像のプロットツールを作成したのでカオスになるのがよくわかる。
  • 2章:Writing Simple Programs
    • Pythonでの数値の取扱い方。基本的な内容。
  • 3章:Computing with Numbers
    • mathライブラリの紹介
    • intとLong int。
    • ビルトイン関数roundで丸めることができる。
  • 4章:Computing with Strings
    • inputとraw_inputの違い。
>>> firstName = input("Please enter your name: ")
Please enter your name: John  <---エラーになる場合

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    firstName = input("Please enter your name: ")
  File "<string>", line 1, in <module>
NameError: name 'John' is not defined

>>> firstName = input("Please enter your name: ")
Please enter your name: "John" <---エラーにならない場合
>>>