booleans: truth table


Sometimes I want programs to make decisions based on inputs or conditions, and can make this happen with if statements.

These are exercises on writing conditional expressions in Python using the Truth Table from Mathematics

requirements

  • I open a terminal to run makePythonTdd.sh with truth_table as the name of the project

    ./makePythonTdd.sh truth_table
    

    on Windows without Windows Subsystem Linux use makePythonTdd.ps1

    ./makePythonTdd.ps1 truth_table
    

    it makes the folders and files that are needed, installs packages, runs the first test, and the terminal shows AssertionError

    E       AssertionError: True is not false
    
    tests/test_truth_table.py:7: AssertionError
    
  • I hold ctrl (windows/linux) or option (mac) on the keyboard and use the mouse to click on tests/test_truth_table.py:7 to open it in the editor

  • then change True to False to make the test pass

  • I add an import statement

    import unittest
    import src.truth_table
    

Operations


how to run automated tests if you exit

cd truth_table
source .venv/bin/activate
pytest-watch

how to run automated tests on Windows without WSL if you exit

Warning

This is for Windows without Windows Subsystem Linux

cd truth_table
.venv/scripts/activate.ps1
pytest-watch

truth table: tests and solutions