Difference between revisions of "Python Boolean Exercises"
From WLCS
Line 9: | Line 9: | ||
==Directions== | ==Directions== | ||
# Open Wing IDE 101 | # Open Wing IDE 101 | ||
− | # | + | # Write short Python programs to complete the exercises below |
==References== | ==References== | ||
− | * [[Media: | + | * [[Media:BooleanLogic.ppt]] |
− | |||
==Exercises== | ==Exercises== | ||
Line 21: | Line 20: | ||
*# Using a single if-else statement, print out whether or not they can purchase a slurpee | *# Using a single if-else statement, print out whether or not they can purchase a slurpee | ||
*#* To buy a slurpee, the user needs to be near a 7-11 AND have at least $3 | *#* To buy a slurpee, the user needs to be near a 7-11 AND have at least $3 | ||
+ | |||
+ | * Checked Baggage Exercise | ||
+ | *# Prompt the user for the number of bags they have with them | ||
+ | *# Prompt the user and ask them if they have any bags over 50 lbs (yes/no) | ||
+ | *# Using a single if statement, print out whether or not they can check their bags if they have more than zero bags AND no bags over 50 lbs | ||
+ | |||
* | * |
Revision as of 07:15, 1 October 2012
Contents
Objectives
- You will learn to use if-statements to control program flow
- You will learn to write Boolean logic expressions
- You will learn to combine multiple logic expressions using:
- and
- or
- not
Directions
- Open Wing IDE 101
- Write short Python programs to complete the exercises below
References
Exercises
- Slurpee Exercise
- Prompt the user to see if they are near a 7-11 (yes/no)
- Prompt the user to see how much money they have
- Using a single if-else statement, print out whether or not they can purchase a slurpee
- To buy a slurpee, the user needs to be near a 7-11 AND have at least $3
- Checked Baggage Exercise
- Prompt the user for the number of bags they have with them
- Prompt the user and ask them if they have any bags over 50 lbs (yes/no)
- Using a single if statement, print out whether or not they can check their bags if they have more than zero bags AND no bags over 50 lbs