28. コマンドラインからPython3
$ python3.6
Python 3.6.0 (default, Dec 4 2017, 04:10:59) [GCC 4.9.2] on
linuxType "help", "copyright", "credits" or "license" for more
information.
>>> print("hello, python!")
hello, python!
こんな感じで、気軽にコマンドラインから利用できる。
$ python だとpython2系が
起動する 注意!
29. Python3の文法をガーっと学ぶ
>>> a = 10
>>> b = 20
>>> print(a+b)
30
C言語だと
#include <stdio.h>
int main(){
int a = 10;
int b = 20;
printf(“%d”, a+b);
return 0;
}
37. Python3の文法をガーっと学ぶ
*リスト内包
>>> a = [ i for i in range(10) ]
>>> print(a)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> b = [ i**2 for i in range(10) if i%2 == 0 ]
>>> print(b)
[0, 4, 16, 36, 64]