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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.