1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Ilia_Sergeevich [38]
3 years ago
15

What does this mean in python?

Computers and Technology
1 answer:
scoundrel [369]3 years ago
8 0

the comments in the code should explain everything, brainly's formatting might be weird


gate = raw_input("Enter logic gate :").upper()#.upper() so lower/upper case of input doesn't matter

firstInput = raw_input("Enter first input :")#raw_input() for python 2.7, input() for 3

secondInput = raw_input("Enter second input :")

if (firstInput!="0" and firstInput!="1") or (secondInput!="0" and secondInput!="1"):

print("inputs must be 0 or 1")#ensure all inputs are in boolean range

quit()


firstInput=firstInput=="1"#convert "1" to true and "0" to false

secondInput=secondInput=="1"


if gate=="AND" or gate=="NAND":

result=firstInput and  secondInput

elif gate=="OR" or gate=="NOR":

result=firstInput or secondInput

elif gate=="XOR":

result=firstInput!=secondInput

else:#handle case of unknown/mistyped gates

print(gate+" is not known")

quit()

if gate=="NOR" or gate=="NAND":

result=not result#invert result for nor and nand

print("Result = "+str(int(result)))#uses int so 1/0 are printed instead of True/False


You might be interested in
How does a film establish the setting?
ololo11 [35]

Answer:

Establishing Shots are critical in a film. They clue the viewer where this next scene is about to take place. Each time the location of a scene shifts, a new establishing shot does exactly; what its name implies: it establishes where the story will now continue, and fiction writers need to do the same thing.

Explanation:

8 0
3 years ago
What was the first computer to defeat a world champion chess player?
deff fn [24]
deep blue IBM's chess-playing computer
6 0
3 years ago
. In Laissez-faire Styleof Group Leadership, Members of the group are not given help inactivity plans by the leader only when it
Trava [24]

Answer:

The statement is false.

Explanation:

In Laissez-faire Style of group leadership, the members of the group are given all the responsibilities by the leader or the manager. The members of the group take all the decisions and control the working of the group. The manager provides with some guidance or support only when it is asked by the group members.

4 0
3 years ago
What is the output of the following code? Select all that apply c=0 while ( c < 11 ) c = c + 6
Andreyy89

Answer:

crop=6

Explanation:

6 0
1 year ago
Which of the following is not recommended? A. Vehicle occupants should wear both lap and shoulder belts. B. Vehicle occupants sh
MA_775_DIABLO [31]
C. children 13 and under
4 0
3 years ago
Other questions:
  • What device brocasts all data packets to other nodes on a network?
    5·1 answer
  • What does utp stand for?
    11·2 answers
  • The process of engineering design typically starts with what ?
    12·1 answer
  • A(n) ____________________ is a set of programs that coordinates all the activities among computer or mobile device hardware.
    10·1 answer
  • Give a logical expression with variables p,q, and r that is true if p and q are false and r is true and is otherwise false.
    5·1 answer
  • A nonpipelined system takes 300ns to process a task. The same task can be processed in a 5-segment pipeline with a clock cycle o
    10·1 answer
  • Which type of computer is the best? laptop, tablet, or desktop
    15·2 answers
  • Advantages of e commerce
    14·1 answer
  • For a new version of processor, suppose the capacitive load remains, how much more energy will the processor consume if we incre
    12·1 answer
  • Hannah is editing her brother’s birthday video. She has selected the usable shots and copied them onto her computer. What is the
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!