Difference between revisions of "Python Boolean Exercises"
From WLCS
(→Exercises) |
|||
Line 29: | Line 29: | ||
*# Prompt the user for their number grade (0-100) | *# Prompt the user for their number grade (0-100) | ||
*# Use a series of if-statements and Boolean '''and''' to print out their letter grade | *# Use a series of if-statements and Boolean '''and''' to print out their letter grade | ||
− | *#* Use this [http://www.paulbui.net/wl/Computer_Science_I_Syllabus#Organization grade chart | + | *#* Use this [http://www.paulbui.net/wl/Computer_Science_I_Syllabus#Organization grade chart] as a guide |
Latest revision as of 07:20, 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
- Letter Grade Calculator
- Prompt the user for their number grade (0-100)
- Use a series of if-statements and Boolean and to print out their letter grade
- Use this grade chart as a guide