Library > 工学 > プログラミング・アルゴリズム > Python



Python:実践編

import thisと打つと、、
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!

標準出力

print("")

標準入力?

name = input("お名前は?")
print("こんにちは %s" % (name))
~.pyと保存して、
python3 ~.pyと実行する。

繰り返し

for文

def  main():
	""" Function doc """

	for i in range(1, 6):
		print("%s" % i)

if __name__ == "__main__":
	main()

計算系モジュール

import math

import cmath

from fractions import Fraction

import numbers

import decimal import Decimal

科学技術計算系

numpy

apt-get install python3-numpy

scipy

apt-get install python3-scipy

matplotlib

apt-get install python3-matplotlib

Blender,,,3Dを取り扱う

  • インストール
  • apt-get install blender

スパースモデリング...フランスInriaの公開コード

Python:理論編

Perfect Python

  • 3.xと2.xで言語仕様が違うらしいな。

良さげな本。てかあんまり選択しなかった。グラフとか書けるんだあみたいな。 3.x対応らしい。

初めてのPython 第3版

分厚い本。7章くらいで、やめた。

Pythonライブラリ厳選レシピ

いろいろ参考になりそうなのが書いてありそう。

IPython データサイエンスクックブック

おもしろそうな応用例が書かれている。

Pythonによるデータ分析入門

グラフプロット

開発環境とか

統合開発環境としてのGeany

  • これがよさそうだと思う。Windowsでも使える。

Python2系と3系の共存

Ubuntu15.10では、最初から共存した状態だった。pythonと打つと2系が、python3と打つと3系が動作する。 Ubuntu12では、後入れで入れてた。

http://blog.yubais.net/21.html

ライブラリ

学術系ライブラリ,Scipy,Numpy,matplotlib,,,

pipというツールでライブラリ管理を行っている。
easy_install pip

pip install numpy
pip install scipy
pip install matplotlib


pip install scikit-learn

使い方


  • 簡単な例
import numpy as np
import matplotlib.pyplot as plt
x= np.arange(-3,3,0.1)
y=np.sin(x)
plt.plot(x,y)
imshow(x,y)

リンク集

Pythonを海洋(気候)物理学に使う。

朱鷺の杜

プロジェクト

東京scipy

最終更新:2021年06月06日 14:05
添付ファイル