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
sweet [91]
3 years ago
6

Write a Python program that will take as input 5 integer values and will output the average of the odd values and the average of

the even values that were input. You will need to use if and elif statements to classify each value as odd or even. Be sure to keep track of how many odd values and even values you have, so you can calculate the correct average for each set of values.

Computers and Technology
1 answer:
8_murik_8 [283]3 years ago
6 0

Code:

Here is the code. Also screenshot of the code and text file containing the code have been attached here.

This code has been written in Python 3.0

# getting input

lst = [ ]  

n = 5  

for i in range(0, n):  

   ele = int(input())  

   lst.append(ele)

print(lst)

# getting odd numbers and even numbers from list and compute average

odd_sum = 0

even_sum = 0

odd = 0

even = 0

for i in range(0, n):  

   if lst[i] % 2 == 0:

       even_sum = even_sum + lst[i]

       even = even + 1

   elif lst[i] % 2 > 0:

       odd_sum = odd_sum + lst[i]

       odd = odd + 1

       

odd_avg = odd_sum/odd

even_avg = even_sum/even

print("there were",odd,"odd numbers in input")

print("there were",even,"odd numbers in input")

print("average of odd numbers in the list",odd_avg)

print("average of even numbers in the list",even_avg)

You might be interested in
Can you shoot video on the Olympus E-410?
Masja [62]
Yes you must update or do something first but then you can
6 0
3 years ago
Read 2 more answers
How did machines get involved throughout the years?
Nataliya [291]

Answer:

Although the primary goal of a political machine is keeping itself in power rather than providing good government, machines have been responsible for restructuring city governments to centralize authority, improving facilities and services, helping to assimilate immigrant groups, and encouraging the growth of business and industry. Supporters of political machines say that they “work” and that consolidating power in the hands of a boss.

Explanation:a political machine is a political group in which an authoritative leader or small group command the support of a corps of supporters and businesses

4 0
3 years ago
When creating an electronic slide presentation, Lee should avoid
Amanda [17]

I believe the answer is <u>Using sound effects between slides.</u>

Using sound effects between slides can cause for a distraction, and if you are in college, your professor may not score your presentation as well as if it were made without sound effects. Hope this helps!

5 0
3 years ago
write HTML code to create a web page which will contain a title my favourite book as a centralised heading feluda somogro and bo
Trava [24]

Answer:

Satyajit Ray (1921–1992), a Bengali film director from India, is well known for his contributions to Bengali literature. He created two of the most famous characters in Feluda the sleuth, and Professor Shonku the scientist. He wrote several short novels and stories in addition to those based on these two characters. His fiction was targeted mainly at younger readers (mostly teenagers) , though it became popular among children and adults alike.



Ray during recording of his film Pather Panchali

Most of his novels and stories in Bengali have been published by Ananda Publishers, Kolkata; and most of his screenplays have been published in Bengali in the literary journal Ekshan, edited by his close friend Nirmalya Acharya. During the mid-1990s, Ray's film essays and an anthology of short stories were also published in the West. Many of the stories have been translated into English and published.

3 0
3 years ago
The critical path in a project network is:______ A. The Shortest path through the network. B. Longest path through the network.
Softa [21]

Answer:

B

Explanation:

4 0
3 years ago
Other questions:
  • You’ve received a tarball called data79.tar from a colleague, but you want to check the names of the files it contains before ex
    15·1 answer
  • When should you use the Reply All function when replying to an email
    10·2 answers
  • What parts of the computer does it not need to function?​
    9·1 answer
  • (Financial application: compound value) Suppose you save $100 each month into a savings account with the annual interest rate 5%
    8·1 answer
  • Why does everyone refer to dogs as being loyal
    11·2 answers
  • When looking at a relationship between two tables on an ERD, the _____ table can be identified by the presence of a foreign key
    8·1 answer
  • Which of the following is a message sent from one person to another using the Internet?
    13·2 answers
  • A computer program that enables users to create and work with files and folders is called what?
    8·2 answers
  • Input 3 positive integers from the terminal, determine if tlrey are valid sides of a triangle. If the sides do form a valid tria
    6·1 answer
  • WHICH PROGRAMMING LANGUAGES ARE THE BEST FOR PROGRAMMING?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!