Difference between revisions of "Python Boolean Exercises"

From WLCS
(Created page with "==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 expres...")
 
Line 16: Line 16:
  
 
==Exercises==
 
==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
 +
*

Revision as of 13:37, 27 September 2012

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

  1. Open Wing IDE 101
  2. Complete the following Python exercises

References

Exercises

  • Slurpee Exercise
    1. Prompt the user to see if they are near a 7-11 (yes/no)
    2. Prompt the user to see how much money they have
    3. 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