Question: Question 1 - Python directly supports conjunction and disjunction in terms of the built-in primitives and and or, as well as negation via the primitive
Question 1 - Python directly supports conjunction and disjunction in terms of the built-in primitives and and or, as well as negation via the primitive not. Other connectives can easily be encoded as functions by use of the if statement. The implication arrow, for example, may be defined as follows: def implies(a, b): ifa: return b else: return True To express the logical statement x 20 1 y 20 --**y 20 in Python one simply writes implies( x >= 0 and y >=0, x*y>=0 ) Notice, though, that the Python interpreter will merely check whether the implication statement holds for the particular values assigned to x and y at run-time. To check the validity of the statement in general, one has to run it for every possible combination of values for x and y-a daunting task even considering the limited range of Python's integers! Exercise: Write a Python program that prints the truth table for the expression pq v r). The table should contain a row for each possible combination of values for variables p, q and r. and columns for the final result as well as each relevant boolean subexpression
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
