On 26/09/2017 01:15, Cai Gengyang wrote:
"""
      Boolean Operators
------------------------
True and True is True
True and False is False
False and True is False
False and False is False

True or True is True
True or False is True
False or True is True
False or False is False

Not True is False
Not False is True

"""

If I simply want to print a chunk of words and a paragraph like the above, what 
command should I use ?


If you are looking for quiet mode code I suggest you stick to the answer given by Chris Angelico earlier.

If you want verbose aka Steven D'Aprano :) mode code how about:-

from operator import and_, or_
from itertools import product

print('''
     Boolean Operators
------------------------
''', end='')

l = {and_: 'and', or_: 'or'}
bools = (True, False)
for logic in (and_, or_):
    for a, b in product(bools, repeat=2):
        ans = logic(a, b)
        print(f'{a} {l[logic]} {b} is {ans}')
    print()
for b in bools:
    print(f'Not {b} is {not b}')

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

---
This email has been checked for viruses by AVG.
http://www.avg.com


--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to