Python 読解ガイド

コードを書かずに「読める」ようになるためのインタラクティブ教科書

01. 基礎(Basics)
1
変数(variable)Interactive
データを入れる箱。= の読み方、上書き、自己更新
2
関数(function)Interactive
def で定義、() で呼び出す。処理のまとまり
3
引数と戻り値(parameters)Interactive
関数への入出力。位置引数、キーワード引数、デフォルト値
4
条件分岐(conditionals)Interactive
if / elif / else で分岐。比較演算子と論理演算子
5
繰り返し(loops)Interactive
for と while。range、break、continue
6
リスト(list)Interactive
順序付きのコレクション。append、sort、インデックス
7
辞書(dictionary)Interactive
キーと値のペア。get、items、update
8
文字列と数値(strings & numbers)Interactive
str、int、float、型変換、演算
9
真偽値とNone(boolean & None)Interactive
True / False / None。真偽判定、is演算子
10
モジュールとインポート(import)Interactive
import、from ... import、as、標準ライブラリ
11
クラス(class)Interactive
オブジェクトの設計図。属性とメソッド
12
メソッド(method)Interactive
オブジェクトの動作。self、インスタンスメソッド
13
例外処理(try / except)Interactive
エラーを捕捉する。try / except / finally
14
非同期処理(async / await)Interactive
async def、await、イベントループの基本
15
型ヒント(type hints)Interactive
関数の入出力に型を注釈。Optional、Union
16
デコレータ(decorator)Interactive
関数を包む関数。@構文、ラッパー
17
コンテキストマネージャ(context manager)Interactive
with文の仕組み。__enter__ / __exit__
18
演算子(operators)Interactive
算術・比較・論理・ビット演算子。優先順位
19
文字列操作(string operations)Interactive
split、join、replace、strip、format
20
ファイル入出力(file I/O)Interactive
open、read、write。with文で安全にファイル操作
02. Python構文(Syntax)
1
インデント(indentation)Interactive
Pythonのブロック構造。スペース4つのルール
2
f文字列(f-string)Interactive
変数を文字列に埋め込む。f"..." 構文
3
リスト内包表記(list comprehension)Interactive
1行でリストを生成。[式 for 変数 in イテラブル]
4
with文(with statement)Interactive
リソースの自動解放。openの安全な使い方
5
*args / **kwargsInteractive
可変長引数。タプルと辞書で受け取る
6
__init__ と selfInteractive
コンストラクタと自分自身への参照
7
lambda(ラムダ式)Interactive
名前なし関数。sortedやmapと組み合わせ
8
ジェネレータ(generator)Interactive
yieldで値を順次生成。メモリ効率の良いイテレーション
9
スライス(slicing)Interactive
[start:stop:step] で部分取得。文字列・リスト共通
10
例外の種類(exception types)Interactive
ValueError、TypeError等の組み込み例外とカスタム例外