SST Lab Dokuwiki Header
内容へ移動
@surface
ユーザ用ツール
ログイン
サイト用ツール
検索
ツール
文書の表示
以前のリビジョン
バックリンク
最近の変更
メディアマネージャー
サイトマップ
ログイン
>
最近の変更
メディアマネージャー
サイトマップ
トレース:
制御構造
この文書は読取専用です。文書のソースを閲覧することは可能ですが、変更はできません。もし変更したい場合は管理者に連絡してください。
====== 即席ヘビつかい講座 ====== * [[データ構造|データ構造]] * [[入出力|入出力]] * [[制御構造|制御構造]] * [[関数・外部手続き|関数・外部手続き]] ===== 制御構造 ===== ==== 単純if文 ==== <code python> >>> a = 1 >>> if (a == 1): ... print 'a = 1' ... a = 1 </code> 比較演算子は >, >=, <, <=, ==, != で c言語等と同じ <code python> >>> if (a >= 1): ... print 'a >= 1' ... a >= 1 >>> if (a > 1): ... print 'a > 1' ... >>> </code> ==== ブロックif文 ==== ブロックはインデントで指定する <code python> >>> if (a >= 0): ... print 'Positive' ... else: ... print 'Negative' ... Positive >>> </code> ==== for文 ==== for 変数 in リスト: <code python> >>> for a in [1, 2, 4]: ... print a ... 1 2 4 </code> print ,は改行しない <code python> >>> for a in [1, 2, 4]: ... print a, ... 1 2 4 >>> </code> 1から10までの和 <code python> >>> a = 0 >>> for i in range(1, 11): ... a = a + i ... print i, a ... 1 1 2 3 3 6 4 10 5 15 6 21 7 28 8 36 9 45 10 55 >> </code>
制御構造.txt
· 最終更新: 2022/08/23 13:34 by
127.0.0.1
ページ用ツール
文書の表示
以前のリビジョン
バックリンク
文書の先頭へ