python:features
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
python:features [2016/07/13 21:53] – created mithat | python:features [2017/12/06 01:54] (current) – [if, if/else] mithat | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Some Python features ====== | ====== Some Python features ====== | ||
+ | ===== Types ===== | ||
+ | ==== Boolean ==== | ||
<code python> | <code python> | ||
- | if foo == bar: # header (a specific keyword followed by a colon) clause + | + | True |
- | | + | False |
- | ... # | + | |
- | else # header | + | |
- | print(' | + | |
- | ... # | + | |
</ | </ | ||
+ | |||
+ | ===== Header, suite/ | ||
+ | <code python> | ||
+ | if foo == bar: # header | ||
+ | print(' | ||
+ | else: # header | ||
+ | print(' | ||
+ | </ | ||
+ | |||
+ | ===== Selection ===== | ||
+ | ==== if, if/else ==== | ||
+ | |||
+ | <code python> | ||
+ | if condition: | ||
+ | suite | ||
+ | </ | ||
+ | |||
+ | <code python> | ||
+ | if condition: | ||
+ | suite | ||
+ | else: | ||
+ | suite | ||
+ | </ | ||
+ | |||
+ | === nested if/else === | ||
+ | |||
+ | <code python> | ||
+ | if credits == 90: | ||
+ | print(' | ||
+ | else | ||
+ | if credits == 60: | ||
+ | print(' | ||
+ | else: | ||
+ | if credits >= 40: | ||
+ | print(' | ||
+ | else: | ||
+ | print(' | ||
+ | </ | ||
+ | |||
+ | <code python> | ||
+ | if credits >= 90: | ||
+ | print(' | ||
+ | elif credits >= 60: | ||
+ | print(' | ||
+ | elif credits >= 40: | ||
+ | print(' | ||
+ | else: | ||
+ | print(' | ||
+ | </ | ||
+ | |||
+ | ===== Iteration/ | ||
+ | <code python> | ||
+ | while condition: | ||
+ | suite: | ||
+ | </ | ||
+ | |||
+ | **definite loop**: counter controlled repetition, "a program loop in which the number of times the loop will iterate can be determined before the loop is executed." | ||
+ | |||
+ | **indefinite loop**: sentinel controlled repetition, "a program loop in which the number of times the loop will iterate is not known before the loop is executed." | ||
+ | |||
+ | **flag/ |
python/features.1468446800.txt.gz · Last modified: 2016/07/13 21:53 by mithat