Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ラズパイ講習会 No2.5

Avatar for teru0x1 teru0x1
January 09, 2018

ラズパイ講習会 No2.5

Pythonの文法について説明するおまけ回

Avatar for teru0x1

teru0x1

January 09, 2018
Tweet

More Decks by teru0x1

Other Decks in Technology

Transcript

  1. https://gist.github.com/dschep/24aa61672a2092246eaca2824400d37f を⾒ながら進めよう。 $ sudo apt update $ sudo apt install

    build-essential tk-dev libncurses5-dev libncursesw5- dev libreadline6-dev libdb5.3-dev libgdbm-dev libsqlite3-dev libssl- dev libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev $ wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tar.xz $ tar xf Python-3.6.0.tar.xz $ cd Python-3.6.0 $ ./configure $ make $ sudo make altinstall wgetコマンド︓webからダウンロード makeコマンド︓ソフトウェアのビルド つまりコンパイル&ライブラリのリンク
  2. rootについて ならrootじゃないといじれないファイルはどうするのか n そんな時にはコマンドの前にsudo(superuser do) をつける。 n $ sudo nano

    hogehoge n 普通はsudo付きでコマンド実⾏しようとするとパ スワード⼊⼒が求められる・・・。
  3. コマンドラインから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系が 起動する 注意︕
  4. 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; }
  5. 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]