Conditional Statements and Control
Conditional Statements and Control
WARM-UP
response = 'Y'
String - a data type that can contain letters, numbers, and symbols. answer = "Left"
if answer == "Left"
Comparators - compares two values using >, < , <= ,>=, ==. For
print "The answer is Left"
example, 5 > 6. Note: that == compares whether two things are equal,
print "Thank You"
and = assigns a value to a variable.
PROGRAMMING EXERCISES
(Requires IDLE 2.7.10)
Boolean Operators - compare statements and result in boolean
values. There are three boolean operators: and, or, not.
#1: Twinkies!
Create an if statement that checks whether a number of Twinkies (in the variable
Conditional Statement - executes some specified code after
twinkies) is less than 100 or greater than 500. Your program should print the message
checking if its expression is True. If this expression is true, run this
indented code block; otherwise, run this code after the else statement. Too few or too many if the condition is true.
VOCABULARY
PROGRAMMING CHALLENGE # 1
(Prerequisite: Completed PygLatin Module)
Mad Libs
In this activity you will program a classic game called 'Mad Libs' where
users will input parts of speech and create their own story!
Hint: It will require using the raw_input() function to receive input from
the user and string formating syntax, %s.