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
If you see these REPORT.
Alenkinab [10]

Answer:

ok will do

Explanation:

3 0
3 years ago
Read 2 more answers
How do you get a code in C to count down from 5??
Valentin [98]

Answer:

This is what the code should do:

“Lift off in T minus

5

4

3

2

1

Blast-off!”

When I run it, it just keeps printing ''Sum = 5'' forever.

Explanation:

Code:

int main(void) {

int sum = 5;  

int i;      

printf("Lift off in T minus\n");

for (i = 0; i < 5; i=i+i) {

   sum = sum - i;  

   printf("sum = %d\n",sum);  

}  

printf("Blast-off",sum);  

return 0;

5 0
4 years ago
Is it possible to do calculations with text data in Ms Excel
ss7ja [257]
The answer for this question is YES
3 0
3 years ago
Read 2 more answers
Questions about the data policy and privacy policy of YT
Ilya [14]

Answer:

I'm confused

Explanation:

7 0
3 years ago
What is responsible for what u see on a computer monitor?
zhuklara [117]
What is responsible or who is responsible?
3 0
4 years ago
Other questions:
  • What are some options available when using the Replace feature?
    13·1 answer
  • Which processor interrupts the system 18.2 times per second? What are some of its practical uses?
    7·1 answer
  • Write a sentence about a mineral you use and how you use it
    12·1 answer
  • What is a series of instructions or commands that a computer follows used to create software
    9·1 answer
  • Cloud resources are​ ________ because many different organizations use the same physical hardware.
    12·1 answer
  • Jabari is writing a program which prompts a user for a value with a decimal. Which function should he use? float() int() print()
    9·2 answers
  • What is the name of the process that weighs the alternatives, gathers all necessary information, and can ultimately lead you to
    9·2 answers
  • Word documents contain how many sections by default?
    9·1 answer
  • Group of answer choices When declaring a variable, you also specify the type of its values. Variables cannot be assigned and dec
    7·1 answer
  • Which of the following expressions in Java is equal to 4?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!