{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

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

View Full Document Right Arrow Icon
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
Background image of page 1

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

View Full Document Right Arrow Icon
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
Background image of page 2
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’
Background image of page 3

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

View Full Document Right Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}