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 ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern