Difference between revisions of "Python Boolean Exercises"

From WLCS
(Exercises)
 
(One intermediate revision by the same user not shown)
Line 26: Line 26:
 
*# 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
 
*# 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 [http://www.paulbui.net/wl/Computer_Science_I_Syllabus#Organization grade chart] as a guide

Latest revision as of 07:20, 1 October 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. Write short Python programs to complete the exercises below

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
  • Checked Baggage Exercise
    1. Prompt the user for the number of bags they have with them
    2. Prompt the user and ask them if they have any bags over 50 lbs (yes/no)
    3. 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
    1. Prompt the user for their number grade (0-100)
    2. Use a series of if-statements and Boolean and to print out their letter grade