Lesson 01/15 – Go With The Flow
[code lang=”python”]
def clinic():
print "You’ve just entered the clinic!"
print "Do you take the door on the left or the right?"
answer = raw_input("Type left or right and hit ‘Enter’.").lower()
if answer == "left" or answer == "l":
print "This is the Verbal Abuse Room, you heap of parrot droppings!"
elif answer == "right" or answer == "r":
print "Of course this is the Argument Room, I’ve told you that already!"
else:
print "You didn’t pick left or right! Try again."
clinic()</p>
<p>clinic()
[/code]
Lesson 02/15 – Compare Closely!
[code lang=”python”]</p>
<h1>Assign True or False as appropriate on the lines below!</h1>
<p>bool_one = True</p>
<p>bool_two = True</p>
<p>bool_three = False</p>
<p>bool_four = False</p>
<p>bool_five = False
[/code]
Lesson 03/15 – Compare… Closelier!
[code lang=”python”]</p>
<h1>Assign True or False as appropriate on the lines below!</h1>
<p>bool_one = False</p>
<p>bool_two = True</p>
<p>bool_three = False</p>
<p>bool_four = True</p>
<p>bool_five = False
[/code]
Lesson 04/15 – How the Tables Have Turned
[code lang=”python”]</p>
<h1>Create comparative statements as appropriate on the lines below!</h1>
<h1>Make me true!</h1>
<p>bool_one = 5 == 5</p>
<h1>Make me false!</h1>
<p>bool_two = 4 == 5</p>
<h1>Make me true!</h1>
<p>bool_three = 20 + 3 &lt; 25</p>
<h1>Make me false!</h1>
<p>bool_four = 23 – 13 == 20</p>
<h1>Make me true!</h1>
<p>bool_five = (20 + 10) * 2 &gt;= 60
[/code]
Lesson 05/15 – To Be and/or Not to Be
[code lang=”python”]
"""</p>
<h2>Boolean Operators</h2>
<p>True and True is True
True and False is False
False and True is False
False and False is False</p>
<p>True or True is True
True or False is True
False or True is True
False or False is False</p>
<p>Not True is False
Not False is True</p>
<p>"""
[/code]
Lesson 06/15 – And
[code lang=”python”]
bool_one = False</p>
<p>bool_two = False</p>
<p>bool_three = False</p>
<p>bool_four = True</p>
<p>bool_five = True
[/code]
Lesson 07/15 – Or
[code lang=”python”]
bool_one = True</p>
<p>bool_two = True</p>
<p>bool_three = False</p>
<p>bool_four = True</p>
<p>bool_five = False
[/code]
Lesson 08/15 – Not
[code lang=”python”]
bool_one = False</p>
<p>bool_two = True</p>
<p>bool_three = True</p>
<p>bool_four = True</p>
<p>bool_five = False
[/code]
Lesson 09/15 – This and That (or This, But Not That!)
[code lang=”python”]
bool_one = False</p>
<p>bool_two = True</p>
<p>bool_three = True</p>
<p>bool_four = True</p>
<p>bool_five = False
[/code]
Lesson 10/15 – Mix ‘n’ Match
[code lang=”python”]</p>
<h1>Use boolean expressions as appropriate on the lines below!</h1>
<h1>Make me false!</h1>
<p>bool_one = not True</p>
<h1>Make me true!</h1>
<p>bool_two = True or not True</p>
<h1>Make me false!</h1>
<p>bool_three = False and False</p>
<h1>Make me true!</h1>
<p>bool_four = True or not (True or False)</p>
<h1>Make me true!</h1>
<p>bool_five = False or True
[/code]
Lesson 11/15 – Conditional Statement Syntax
[code lang=”python”]
response = "Y"</p>
<p>answer = "Left"
if answer == "Left":
print "This is the Verbal Abuse Room, you heap of parrot droppings!"</p>
<h1>Will the above print statement print to the console?</h1>
<h1>Set response to ‘Y’ if you think so, and ‘N’ if you think not.</h1>
<p>[/code]
Lesson 12/15 – If You’re Having…
[code lang=”python”]
def using_control_once():
if 0 == 0:
return "Success #1"</p>
<p>def using_control_again():
if 8 &lt; 9:
return "Success #2"</p>
<p>print using_control_once()
print using_control_again()
[/code]
Lesson 13/15 – Else Problems, I Feel Bad for You, Son…
[code lang=”python”]
answer = "’Tis but a scratch!"</p>
<p>def black_knight():
if answer == "’Tis but a scratch!":
return True
else:
return False # Make sure this returns False</p>
<p>def french_soldier():
if answer == "Go away, or I shall taunt you a second time!":
return True
else:
return False # Make sure this returns False
[/code]
Lesson 14/15 – I Got 99 Problems, But a Switch Ain’t One
[code lang=”python”]
def greater_less_equal_5(answer):
if answer &gt; 5:
return 1
elif answer &lt; 5:
return -1
else:
return 0</p>
<p>print greater_less_equal_5(4)
print greater_less_equal_5(5)
print greater_less_equal_5(6)
[/code]
Lesson 15/15 – The Big If
[code lang=”python”]
def the_flying_circus():
if True and True:
return True
elif 9 != 9:
return False
else:
return "Nothing"
[/code]