Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

language: python The program exits when I enter a connecter 'v' or '^' when I want it to identify the connector and connect the two

language: python

image text in transcribed

The program exits when I enter a connecter 'v' or '^' when I want it to identify the connector and connect the two propositions with "and" or "or". The following is my code. I also want my code to output the complex proposition combined and produce a truth table according to the user's connector input.

I want my output to look something like this:

enter proposition 1: Annie is tall

enter proposition 2: Annie is happy

what is the connector? v

Annie is tall and annie is happy.

is proposition 1 true or false? true

is proposition 2 true or false? false

the complex proposition is false.

AND truth table

T T T

T F F

F T F

F F F

_________________________________

def userInput(): propo1 = input("Enter the proposition 1: ") propo2 = input("Enter the proposition 2: ")

connector = input("What is the connector? (^ for and, v for or): ")

def connector(): if connector == "v": complex_propo = propo1 + " or " + propo2[0].lower() + propo2[1:] elif connector == "^": complex_propo = propo1 + " and " + propo2[0].lower() + propo[1:] else: print("Invalid. Enter ^ or v. " ) exit()

def printcomplexpropo(): print("The complex proposition is: ", complex_prop)

def value(): propo1_value = input("Is proposition 1 true or false? ") if propo1_value == "true": propo1_value = True elif propo1_value == "false": propo_value = False else: print("Invalid. Enter true or false. ") exit()

def value_complex(): andTable = [[T, T, T], [T, F, F], [F, T, F], [F, F, F]]

orTable = [[T, T, T], [T, T, T], [F, T, F], [F, F, F]]

if connector == 'v': for row in orTable: if row [0] == propo1_value and row[1] == propo2_value: complex_prop_value == row [2] print("Complex proposition is ", complex_pop_value ) break print ("OR Truth Table" ) for row in orTable: print(row) elif connector == "^": for row in andTable: if row[0] == propo1_value and row[1] == propo2_value: complex_prop_value == row[2] print ("The complex proposition is ", complex_prop_value) break print ( "AND truth table" ) for row in andTable: print(row)

def main(): userInput() connector() printcomplexpropo() value() value_complex()

main()

Enter the proposition 1: anny be Enter the proposition 2: hi bye What is the connector? (^ for and, v for or): Invalid. Enter or v. v Traceback (most recent call last): File "0>, line 1, in v NameError: name ' v ' is not defined

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Peter Rob, Carlos Coronel

6th International Edition

061921323X, 978-0619213237

More Books

Students also viewed these Databases questions

Question

Describe a persuasive message.

Answered: 1 week ago

Question

Identify and use the five steps for conducting research.

Answered: 1 week ago

Question

List the goals of a persuasive message.

Answered: 1 week ago