RU beehive logo ITEC dept promo banner
ITEC 109
2014spring
ibarland

homeinfolabsexamshws
D2LMediaSamples/breeze (snow day)tutor/PIs

lab36
if-else statements, cont.

We'll start by discussion exam01.

Last time we talked about boolean expressions (and how operators like == (equal), >= (greater-or-equal), < (less-than), != (not-equal), etc. return a boolean (T/F) value).

Although JES treats booleans as 0 or 1 they're not — actual python uses False and True (note the upper-case) and these are different from1 0 and 1.

For the Codingbat.com > Python > Warmup-1 > sum_double, we talked about four ways to compute the answer:

Note that none of these are the same as CodingBat's Show Solution button. That's because their solution violates two good practices, which we will use in this class:


Task: We will work through the following codingbat problems:


1However, int(False) == 0 and int(True) == 1      

2Even if it's … else: None, including the else helps avoid the common bug of forgetting to handle the other case.      

homeinfolabsexamshws
D2LMediaSamples/breeze (snow day)tutor/PIs


©2014, Ian Barland, Radford University
Last modified 2014.Apr.10 (Thu)
Please mail any suggestions
(incl. typos, broken links)
to ibarlandradford.edu
Powered by PLT Scheme