1.1k views
0 votes
Hi there! I just started my beginner computer science class and I was wondering if anyone wants to help with an assignment i'm having trouble with.

Here are the instructions:

Write a program that contains 3 variables and produces the logic table. You will need to request input from the user to set the variables in the form of T or F for each variable. Try to condense your program so you write a single conditional to produce the table. Place the following at the beginning of your code, with all of your code indented to be in that block, so you have a continuous loop:

while True:


I attatched the logic gate to this question.

Thank you!

Hi there! I just started my beginner computer science class and I was wondering if-example-1

1 Answer

0 votes

After looking at your question, I reasoned you were writing this in python. Here's my code, I hope it helps!

while True:

v1 = input("Enter value of first variable (T/F) ")

v2 = input("Enter value of second variable (T/F) ")

v3 = input("Enter value of third variable (T/F) ")

print("v1: {}, v2: {}, v3: {} = T".format(v1, v2, v3) if v1 == "T" and v2 == "T" or v1 == "T" and v3 == "T" else "v1: {}, v2: {}, v3: {} = F".format(v1, v2, v3))

User Jwhazel
by
4.1k points