Write a program, which will take 20, inputs from the user and find how many
odd and even numbers are there.

Pseudocode & Python

Answers

Answer 1

Answer:

user_input = [int(input()) for i in range(20)]

even = []

odd = []

for i in user_input:

if i%2:

even.append(i)

else:

odd.append(i)

print("odd : ", len(odd), "even : ", len(even))

Explanation:

The above code is written in python :

Using a list comprehension we obtain a list of 20 values from the user and store in the variable user_input.

Two empty list are defined, even and odd which is created to store even and odd values.

A for loop is used to evaluate through the numbers in user_input. Even values leave no remainder when Divided by 2 and are appended to the even list while those those leave a raunder are automatically odd values. The elements each list are counted using the len function and are displayed using the print statement.


Related Questions

Other Questions
Find the equation of the line through point (2,2) and parallel to y=x+4. Use a forward slash (i.e./) for fractions (e.g. 1/2 for Every 24 hours, Earth makes a full rotation around its axis. Earth's speed of rotation at the equator is 1.670 km per hour. What is thecircumference of Earth's equator?(Hint. Earth's circumference at the equator is equal to the distance that Earth rotates around the equator). Solve by graphing. Round each answer to the nearest tenth.6x2 = 19x 15a: 2, 1.7b: 1.7, 1.5c: 1.5, 1.5d: 1.5, 1.7 Existen algunas minoras culturales en tu localidad o en tu regin? Averigua sobre una de ellas yelabora un informe.en tu localidad o en tu regin? What are the advantages and disadvantages of using crowdsourced social media data during a disaster response Splish Brothers Inc. reported net income of $394000 for the year. During the year, accounts receivable increased by $29000, accounts payable decreased by $12000 and depreciation expense of $61000 was recorded. Net cash provided by operating activities for the year is 2(5x-3)=24find what x is? If f(a) is an exponential function where f(-3) = 18 and f(1) = 59, then find thevalue of f(0), to the nearest hundredth. write an imaginary conversation between nelson mandela and anne frank. imagine that Nelson Mandela and Anne Frank meet in the afterlife to talk about the extraordinary ordeals in their lives. Think and plan what they would talk about and what common or different views they would have. help plsss1/2x^2 =2If x1 and x2 are the solutions to the equation above,what is the value of x1 + x2?A) 0B) 1C) 2D) 4 Below is a mature eukaryotic mRNA transcript. Translate this mRNA into a protein, also showing the tRNA anticodons involved. Make sure you start and end translation in the right place! Label the ends of the polypeptide chain as N and C terminus.mRNA: 5'GMUUACAUGCGGCUCAGUUGAGGCGAAAAAA 3' tRNA: amino acids: How many molecular of H2O and O2 are present in 8.5g of H2O2 ? Please help with (ii). thank you!!! What is the rate of change of the line on the graph what role does a school play to stop instellaetual migration? explain? O A. y = (x + 3)2 + 5O B. y= (x - 5)2 + 3O c. y = (x + 3)2-5O D. X=-3(y + 5)2 Can someone help me out? Juniper Design Ltd. of Manchester, England, is a company specializing in providing design services to residential developers. Last year the company had net operating income of $430,000 on sales of $1,300,000. The companys average operating assets for the year were $1,500,000 and its minimum required rate of return was 10%.Required:Compute the companys residual income for the year.Average Operating Assets-Net Operating Income-Minimum required return-Residual income- Write a paragraph that makes a point with the help of a strong analogy. Then write a paragraph that uses a weak or false analogy to do the same.If youre having trouble thinking of points or arguments to make, consider using one of the following:Getting rid of all homeworkBeing a bystander to bullyingImposing limits on the use of technologyRemoving age limits on drivers tests Priya, a software developer at SkillThink, is instructed by her team leader to minimize interaction with other team members. However, her project manager says that interacting with other team members can provide new insights for her projects. In this scenario, Priya most likely experiences _____. Group of answer choices interpersonal conflict interrole conflict intrarole conflict