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

Info icon This 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
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
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’
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 ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern