If so tell the user to wear a parka if not tell the

Info iconThis preview shows page 1. Sign up to view the full content.

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

Unformatted text preview: what to wear Check Forecast • 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 Max < -10? TRUE FALSE Wear Parka Wear Shirt Display result Stop 6 2 13 ­09 ­16 The code 7 The code • Note the familiar data processing pa]ern here input calculations output 8 Decision making • The “calcula=on” part of most programs depends on many things (usually provided as input by the user) • In programming languages, we use the “if ­then ­else” construct to make decisions • IF something is true THEN proceed in one way Max < -10? TRUE • ELSE (otherwise), proceed in another way Wear Parka FALSE Wear Shirt 9 3 13 ­09 ­16 Decision making in Python • Python syntax—take 1 if BOOLEAN EXPRESSION : BLOCK1 else : BLOCK2   Each block must contain at least one in...
View Full Document

This document was uploaded on 03/02/2014.

Ask a homework question - tutors are online