Pythonやるお!

卒論大体終わったからPythonやるお!
実は俺まともにかけるLLがひとつもないんだお!
でも、そんな俺でさえちょっとしたプログラムを書くときはLLを使うので、やっぱり便利なんだお。
一つだけでもしっかり使えるようにしておくんだお!


ここから気になった所だけかくお!
http://docs.python.org/release/3.0.1/tutorial/introduction.html

Numbers

>>>#累乗
>>>2**5
32

>>># 床。
>>>7//3
2

>>># 複素数もらくちんちん!
>>>1j*1j
(-1+0j)
>>>1j*complex(0,1)
(-1+0j)
>>>(1+2j)/(1+1j)
(1.5+0.5j)
>>>a=3+4j
>>>a.real
3.0
>>>a.imag
4.0
>>>abs(a)
5.0

String

>>>word = 'help'+'A'
>>>word
'helpA'
>>>#あぁそうなるのね
>>>word*5
'helpAhelpAhelpAhelpAhelpA'
>>>#おおー
>>>word[:2]
'he'
>>>#変更がきかない
>>>word[0]='x'
Traceback (most recent call last):
  File "<pyshell#10>", line 1, in <module>
    word[0]='x'
TypeError: 'str' object does not support item assignment
>>> word[:2]+word[2:]
'helpA'
>>>#マイナスをつけたりすると逆走するじぇ
>>>word[-2:]
'pA'