{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lecture04-conditional-3pp

# Lecture04-conditional-3pp - 130916 Control Flow CMPUT 174...

This preview shows pages 1–4. Sign up to view the full content.

13-09-16’ 1’ Control’Flow’ CMPUT’174’ Example’data’processing’program’ 2’ Start Convert to Celsius Ask temperature Stop Display result Unit’conversion’ input’ calcula=on’ output’ Recap’ A’Python’program’is’a’sequence’of’statements,’typically’ one’per’line’of’the’program’Fle’ The’ assignment’statement ’takes’the’form: 3’ VARIABLE’±’EXPRESSION’ a variable is a name for an address in memory where we store useful data expressions determine how the calculations in the program are made

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
13-09-16’ 2’ Recap’ Recall’that’in’every’memory’address’we’can’only’store’ values’(as’sequences’of’bits)’ We’use’expressions’as’a’convenient’way’of’expressing’ poten=ally’complex’calcula=ons’in’a’single’line’(or’in’a’few’ lines)’ 4’ Recap:’values,’expressions,’types’ 5’ Expressions’can’involve’values’(constants),’variables,’ operators,’and’func=on’calls’ function operators constant variable Your’second’program’ Task :’Ask’the’user’for’temperature’ and’help’him’decide’what’to’wear’ Breakdown’of’task :’ Ask ’user’for’the’forecast’ Decide’ if’it’is’too’cold’to’wear’a’shirt’ If’so,’tell’the’user’to’wear’a’parka’ If’not,’tell’the’user’to’wear’a’shirt’ Print’out ’the’result’ 6’ Start Max < -10? Wear Parka Check Forecast Wear Shirt Stop FALSE TRUE Display result
13-09-16’ 3’ The’code’ 7’ The’code’ Note’the’familiar’data’processing’pa]ern’here’ 8’ input calculations output Decision’making’ The’“calcula=on”’part’of’most’programs’depends’on’many’

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 10

Lecture04-conditional-3pp - 130916 Control Flow CMPUT 174...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online