python:features
This is an old revision of the document!
Table of Contents
Some Python features
Types
Boolean
True False
Header, suite/block, clause
if foo == bar: # header clause 1 print('same') # suite/block clause 1 else: # header clause 2 print('different') # suite/block clause 2
Selection
if, if/else
if condition:
suite
if condition: suite else: suite
nested if/else
if credits == 90: print('Senior') else if credits == 60: print('Junior') else: if credits >= 40: print('Sophomore') else: print('something else')
if credits >= 90: print('Senior') elif credits >= 60: print('Junior') elif credits >= 40: print('Sophomore') else: print('something else')
Iteration/repetition
while condition:
suite:
definite loop: counter controlled repetition
indefinite loop: sentinel controlled repetition
python/features.1468448360.txt.gz · Last modified: 2016/07/13 22:19 by mithat