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
natima [27]
2 years ago
5

Write a program that reads a list of integers, and outputs whether the list contains all even numbers, odd numbers, or neither.

The input begins with
Computers and Technology
1 answer:
Volgvan2 years ago
4 0

Question:

Write a program that reads a list of integers, and outputs whether the list contains all even numbers, odd numbers, or neither. The input begins with an integer indicating the number of integers that follow. Assume that the list will always contain less than 20 integers.

Answer:

Written in Python

listlent = int(input("Length of List: "))

mylist = []

mylist.append(listlent)

for i in range(listlent):

    num = int(input(": "))

    mylist.append(num)

<em>    </em>

evens = 0

odds = 0

for i in range(1,listlent+1):

    if mylist[i]%2==0:

         evens=evens+1

    else:

         odds=odds+1

       

if(evens == 0 and odds != 0):

    print("All Odds")

elif(evens != 0 and odds == 0):

    print("All Even")

else:

    print("Neither")

Explanation:

This prompts user for length of the list

listlent = int(input("Length of List: "))

This initializes an empty list

mylist = []

The following iteration reads the list items from the user

<em>mylist.append(listlent)</em>

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

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

<em>     mylist.append(num)</em>

   

The next two lines initialize even and odd to 0, respectively

<em>evens = 0</em>

<em>odds = 0</em>

<em />

The following iteration if a list item is even or odd

<em>for i in range(1,listlent+1):</em>

<em>     if mylist[i]%2==0:</em>

<em>          evens=evens+1</em>

<em>     else:</em>

<em>          odds=odds+1</em>

This checks and prints if all list items is odd        

<em>if(evens == 0 and odds != 0):</em>

<em>     print("All Odds")</em>

This checks and prints if all list items is even        

<em>elif(evens != 0 and odds == 0):</em>

<em>     print("All Even")</em>

This checks and prints if all list items is neither even nor odd

<em>else:</em>

<em>     print("Neither")</em>

You might be interested in
In your own words, describe how a network administrator can use the OSI model to isolate a network problem.
fenix001 [56]

Answer:

 Network administrator use the open system interconnection model to isolate the network problem as, the network administrator can easily find the problem in the system.

Network administrator regularly depicts issues by the layer number and in many cases the network problem required the network administrator to isolate the issue in which layer the maximum number of issue occurred.

By using the OSI layer, we can easily add protocols to its higher to lower layers without any type of interruption.

3 0
3 years ago
Benjamin recently issued new mobile phones to the marketing team at his company. Each phone can transmit encrypted information f
slava [35]

Answer:

C. NFC

Explanation:

NFC stands for Near Field Communication. NFC is been embedded in recent mobile device (ranging from phone to tablet) to ease payment. NFC is a short-range high frequency wireless communication technology that enables the exchange of data between devices over about a 10 cm distance.

From the option, Bluetooth look like a probable answer but when they are both compared; we realized that NFC has a shorter set-up time over bluetooth and is therefore faster than bluetooth.

3 0
2 years ago
What is lasso tool write the name of any modelling and animation software<br>​
VladimirAG [237]

Explanation:

6579689993 and password is 3250 I RISHAVjoin please I join yar

7 0
3 years ago
_is the joining of two or more electrical conductors by mechanically twisting the conductors together or by using a special spli
adell [148]

Splicing is the joining of two or more electrical conductors by mechanically twisting the conductors together or by using a special splicing device.

Which is an electrical conductor?

An electrical current flows through a conductor because it provides little to no resistance to the movement of electrons. Typically, good electrical conductors include metals, metal alloys, electrolytes, and even some nonmetals like graphite and liquids like water.

What is the purpose of a splice?

It can be used to package and stop the fraying of rope ends as well as as a foundation for more complex knots like the surgeon's knot and the square knot. Wrap the rope end around the standing part to form a loop, then bring the end of the loop through and draw the rope taut to tie an overhand knot.

Is it safe to splice electrical wire?

The splice may overheat and pose a fire risk when the current passes through it. Always utilize a junction box to store all the spliced wires while splicing wires. Any sparks produced during a short circuit are contained in junction boxes, which offer protection from electrocution and fires.

Learn more about electrical conductors: brainly.com/question/28209810

#SPJ4

4 0
1 year ago
True or False? A supervisory control and data acquisition (SCADA) device is a computer that controls motors, valves, and other d
Gekata [30.6K]

Answer:

The correct answer to the following question will be "True".

Explanation:

SCADA is a hardware and software elements program that permits industrial enterprises to:

  • Agricultural processes are regulated locally or globally.
  • The human-machine interaction program specifically interfaces with equipment such as cameras, switches, generators, motors and much more.
  • Track, store, and process the data in real-time.

Therefore, the given statement is true.

4 0
3 years ago
Other questions:
  • When using vlookup, the _____argument is optional?
    8·1 answer
  • What systemctl command configures a unit to start the next time the computer boots?
    10·1 answer
  • The color band that represents tolerance on a resistor is the?
    11·1 answer
  • Which of the following represents the biggest difference between asymmetric and symmetric cryptography?
    9·1 answer
  • If two egg cells are fertilized what will happen?
    10·1 answer
  • In C++ please.
    8·1 answer
  • Hannah decides to burn her video portfolio to a DVD. She wants to hand it over to a movie producer she will meet at a social eve
    15·1 answer
  • _________ can be used to provide access control, confidentiality, data origin authentication, connectionless integrity, rejectio
    12·1 answer
  • Look at the code in the example below, and then answer the question.
    9·1 answer
  • What is an example of work performed by an integration platform as a service (ipaas)?
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!