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
Where do today's computers store almost all motherboard configuration data?
sergij07 [2.7K]
In the mother board of the back door next to the restroom 5 steps left
3 0
3 years ago
The one who will defeat me in this typing race I will mark the one brainliest:
fredd [130]

Answer:

yes

Explanation:

can you send the link....

5 0
2 years ago
Read 2 more answers
Kevin would like to ensure that his software runs on a platform that is able to expand and contract as needs change. Which one o
Reil [10]

A terminology which best describe Kevin's goal in terms of expansion and contraction as needs change is: A. Scalability.

<h3>What is scalability?</h3>

Scalability can be defined as a measure of the ability of a system to change (expansion or contraction) in performance and cost as a result of changes in demands of application and system processing, especially in a network architecture.

In this context, we can logically deduce that a terminology which best describe Kevin's goal in terms of expansion and contraction as needs change is scalability.

Read more on scalability here: brainly.com/question/14301721

#SPJ1

Complete Question:

Kevin would like to ensure that his software runs on a platform that is able to expand and contract as needs change.  Which one of the following terms best describes his goal? A. Scalability B. Elasticity C. Cost effectiveness D. Agility

8 0
1 year ago
Keith would like to compare data he has collected from research. The data includes the electrical output
liberstina [14]

Answer: my test says line graph soooo….

Explanation: if its what the test says

4 0
2 years ago
An administrator needs to make sure that video conferencing is allocated a high portion of bandwidth within a company network. W
frosja888 [35]

Answer:

QoS

Explanation:

We could use a blacklisting or a MAC filtering to remove from the network, and in this way, we're going to get a high portion of bandwidth, but other must work too, and the whitelisting have almost the same function, but QoS Quality of service is specifically for these cases where we need high bandwidth for a video conference, we can make this with some tools or techniques like jitter buffer and traffic shaping.

4 0
3 years ago
Other questions:
  • Why will the standard replacement algorithms (LRU, FIFO, clock) not be effective in handling this workload for a page allocation
    11·1 answer
  • Compare GBN, SR, and TCP (no delayed ACK). Assume that the timeout values for all three protocols are sufficiently long such tha
    7·1 answer
  • I NEED HELP NOW PLEASE!!!!!!
    6·2 answers
  • Preesure is drived quantity? why​
    15·2 answers
  • How does LinkedIn differ from other popular social media platforms? What are the similarities?
    6·1 answer
  • A______ is a graphical representation of numeric data.
    8·1 answer
  • In no less than two paragraphs, explain the risks and compliance requirements of moving data and services into the cloud.
    11·1 answer
  • What is the difference between PowerPoint and Outlook?
    5·1 answer
  • Dynamics simulate stillness via calculations performed by the computer.
    13·2 answers
  • Data becomes _______ when it is presented in a format that people can understand and use.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!