Exercises

Here are some exercises for you to try on your own. Solutions are available at http://pragprog.com/titles/gwpy3/practical-programming.

  1. What value does each expression produce? Verify your answers by typing the expressions into Python.

    1. True and not False
    2. True and not false (Notice the capitalization.)
    3. True or True and False
    4. not True or not False
    5. True and not 0
    6. 52 < 52.3
    7. 1 + 52 < 52.3
    8. 4 != 4.0
  2. Variables x and y refer to Boolean values.

    1. Write an expression that produces True iff both variables are True.
    2. Write an expression that produces True iff x is False.
    3. Write an expression that produces True iff at least one of the variables is True.
  3. Variables full and empty refer to Boolean values. Write an expression that produces ...

Get Practical Programming, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.