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
olchik [2.2K]
3 years ago
15

Write a logical expression using only and, or and not that is equivalent to the Exclusive NOR (XNOR) gate on 2 inputs, called in

1, in2: If both inputs are True or both inputs are False (i.e. inputs have same value), then your expression should evaluate to True. Otherwise your expression should evaluate to False.
Computers and Technology
1 answer:
denis-greek [22]3 years ago
5 0

Answer:

in1 = int(input("Enter value one: "))

in2 = int(input("Enter value two: "))

print(in1,type(in1), in2, type(in2))

if (in1 <=0 and in2 <=0) or (not in1 <=0 and not in2<=0):

   print( True)

else:

   print( False)

Explanation:

The if statement of the python source code is used to implement an Exclusive-NOR logic gate that gives a true or high value if both inputs are either true or false.

You might be interested in
Design a program takes as input, X, an unsorted list of numbers, and returns the sorted list of numbers in X. The program must b
Lelechka [254]

Answer:

The program in python is as follows:

def split(X):

   L = []; G = []

   for i in range(len(X)):

       if X[i]>=X[0]:

           G.append(X[i])

       else:

           L.append(X[i])

   L.sort(); G.sort()

   return L,G

X = []

n = int(input("Length of X: "))

for i in range(n):

   inp = int(input(": "))

   X.append(inp)

   

if len(X) == 0 or len(X) == 1:

   print(X)

else:

   X1,X2=split(X)

   newList = sorted(X1 + X2)

   print(newList)

Explanation:

The following represents the split function in the previous problem

def split(X):

This initializes L and G to empty lists

   L = []; G = []

This iterates through X

   for i in range(len(X)):

All elements of X greater than 0 equal to the first element are appended to G

      <em> if X[i]>=X[0]:</em>

<em>            G.append(X[i])</em>

Others are appended to L

<em>        else:</em>

<em>            L.append(X[i])</em>

This sorts L and G

   L.sort(); G.sort()

This returns sorted lists L and G

   return L,G

The main function begins here

This initializes X

X = []

This gets the length of list X

n = int(input("Length of X: "))

This gets input for list X

<em>for i in range(n):</em>

<em>    inp = int(input(": "))</em>

<em>    X.append(inp)</em>

This prints X is X is empty of has 1 element

<em>if len(X) == 0 or len(X) == 1:</em>

<em>    print(X)</em>

If otherwise

else:

This calls the split function to split X into 2

   X1,X2=split(X)

This merges the two lists returned (sorted)

   newList = sorted(X1 + X2)

This prints the new list

   print(newList)

7 0
2 years ago
What is the most common way to perform searches in a search engine?
valina [46]
Using key words is the best way to search things in the search engine. make sure everything is spelled correctly.
5 0
2 years ago
What type of information is appropriate for headers and footers? Check all that apply.
lbvjy [14]

Answer:

slide/page number

smart art

maybe date and time

Explanation:

6 0
3 years ago
Read 2 more answers
You have to write a program that will read a number followed by a series of bit operations from a file and perform the given ope
tatuchka [14]

The program what will read a number followed by a series of bit operations from file and perform the given operations sequentially on the number is given below.

<h3>What is an operation in computer science?</h3>

An operation, in mathematics and computer programming, is an action that is carried out to accomplish a given task.

There are five basic types of computer operations:

  • Inputting,
  • processing,
  • outputting,
  • storing, and
  • controlling.

<h3>What is the requested program above?</h3>

#include <stdio.h>

#include <fcntl.h>

int main(int argc, char *argv[])

{

  int number, n, v, temp;

  char line[25], fun[10];

  FILE *f = fopen(argv[1], "r");

 

  fgets(line, 24, f);

  sscanf(line, "%d", &number);   //reading the number

  while( fgets(line, 24, f) )

   {

      sscanf(line, "%s %d %d", fun, &n, &v); //reading the commands

      switch(fun[0])           //checking which command to run

      {

          case 'g':    temp = 1;

                      temp = temp<<n;   //shifting for getting that bit

                      printf("%d\n",(number&temp)&&1);

                      break;

          case 's':   temp = 1;

                      temp = temp<<n;   //shifting for setting that bit

                      if(!v)

                      {

                          temp = ~temp;

                          number = number & temp;

                      }

                      else

                      {

                          number = number | temp;

                      }

                      printf("%d\n",number);

                      break;

          case 'c':   temp = 1;

                      temp = temp<<n;   //shifting for complimenting that bit

                      number = number ^ temp;   //xor to complement that bit

                      printf("%d\n",number);

                      break;

          default:printf("not defined");

      }

  }

  return 0;

}

Execution and Output:

terminal-> $ gcc -o first first.c

terminal-> $ ./first file1.txt

1

4

6

Learn more about programs at;
brainly.com/question/16397886
#SPJ1

8 0
1 year ago
Robert and Anne, a married couple filing jointly, have an adjusted gross income of $68,676. They claim two exemptions, and can d
artcher [175]

Answer:

the answer is B

Explanation:

Just took the test

8 0
2 years ago
Read 2 more answers
Other questions:
  • Which of the following typically have the highest auto insurance premiums?
    14·1 answer
  • Which RFC reserves three ranges of IP addresses for private use - a single Class A (10.0.0.0-10.255.255.255), 16 Class Bs (172.1
    15·1 answer
  • A porta power tool is what kind of tool
    9·1 answer
  • You are creating a database for your computer club. Most of the students live in your town, Durham. How can you make Durham appe
    11·1 answer
  • When storing used oil, it needs to be kept in ___________ containers.
    12·1 answer
  • What is the main component of the EV3 Lego Robot called?​
    6·1 answer
  • PLEASE SOMEONE ANSWER THIS
    14·2 answers
  • The small flash memory used in<br>protable device like Laptop<br><br>​
    10·1 answer
  • What are the benefits and risks of a client-server network?
    5·1 answer
  • Which of the following is true about stateless applications?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!