{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Exercice 5" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [], "source": [ "def table_verite_2bits(fonctionbool):\n", " print('|{:^10}|{:^10}|{:^15}|'.format('a','b',fonctionbool.__name__+'(a,b)'))\n", " for a in [True, False]:\n", " for b in [True, False]:\n", " print('|{:^10}|{:^10}|{:^15}|'.format(int(a), int(b), int(fonction(bool(a),bool(b)))))" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "| a | b | __or__(a,b) |\n", "| 1 | 1 | 1 |\n", "| 1 | 0 | 1 |\n", "| 0 | 1 | 1 |\n", "| 0 | 0 | 0 |\n" ] } ], "source": [ "table_verite_2bits(bool.__or__)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.9" } }, "nbformat": 4, "nbformat_minor": 2 }