User Tools

Site Tools


python:features

This is an old revision of the document!


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:
python/features.1468448207.txt.gz · Last modified: 2016/07/13 22:16 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki