差分
このページの2つのバージョン間の差分を表示します。
| 次のリビジョン | 前のリビジョン | ||
| python:if_elif_else [2016/01/12 09:44] – 作成 ともやん | python:if_elif_else [2019/08/19 06:53] (現在) – ともやん | ||
|---|---|---|---|
| 行 1: | 行 1: | ||
| ====== if elif else 文 ====== | ====== if elif else 文 ====== | ||
| - | ===== if 文の制御構造 | + | ===== 一般的な |
| + | <code python> | ||
| + | num = int(raw_input()) | ||
| + | |||
| + | if 10 >= num > 5: | ||
| + | print(' | ||
| + | elif num <= 5: | ||
| + | print(' | ||
| + | else: | ||
| + | print(' | ||
| + | </ | ||
| + | |||
| + | ===== if 以上 以下 ===== | ||
| + | <code python> | ||
| + | num = int(raw_input()) | ||
| + | |||
| + | # (5 <= num) and (num <= 10) と同じ | ||
| + | if 5 <= num <= 10: | ||
| + | print(' | ||
| + | else | ||
| + | print(' | ||
| + | </ | ||
| + | |||
| + | ===== python | ||
| + | <code python> | ||
| + | num = int(raw_input()) | ||
| + | |||
| + | num = 10 if num > 5 else 5 | ||
| + | </ | ||