User Tools

Site Tools


python:features

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
python:features [2016/07/13 21:55] mithatpython:features [2016/07/13 22:10] – [Selection] mithat
Line 1: Line 1:
 ====== Some Python features ====== ====== Some Python features ======
  
-Header, suite/block, clause:+===== Header, suite/block, clause ===== 
 + 
 + 
 +<code python> 
 +if foo == bar        # header             clause 1 
 +    print('same'         # suite/block    clause 1 
 +else:                  # header             clause 2 
 +    print('different'    # suite/block    clause 2 
 +</code> 
 + 
 +===== Selection ===== 
 +==== if, if/else ==== 
 + 
 +<code python> 
 +if condition: 
 +    suite 
 +</code> 
 + 
 +<code> 
 +if condition: 
 +    suite 
 +else: 
 +    suite 
 +</code> 
 + 
 +=== nested if/else === 
 + 
 +<code python> 
 +if credits == 90: 
 +    print('Senior'
 +else 
 +    if credits == 60: 
 +        print('Junior'
 +    else: 
 +        if credits >= 40: 
 +            print('Sophomore'
 +        else: 
 +            print('something else'
 +</code>
  
 <code python> <code python>
-if foo == bar        # header         clause 1 +if credits >90: 
-    print('same'     # suite/block    clause 1 +    print('Senior'
-else:                  # header         clause 2 +elif credits >60
-    print('different'# suite/block    clause 2+    print('Junior') 
 +elif credits >= 40: 
 +    print('Sophomore') 
 +else: 
 +    print('something else')
 </code> </code>
python/features.txt · Last modified: 2017/12/06 01:54 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki