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]
2 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]2 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
What ethical concerns might arise from applying new IT to law enforcement?
pentagon [3]

Answer:

One ethical concern that might occur is the rise of bias in the police department. It would be possible for a disgruntled or frustrated cop to lean into new IT and be able to take advantage of a past suspect or an "enemy" of theirs such as a neighbor or even a coworker.

6 0
2 years ago
Jazmine just finished setting up an operating system that's designed to work between a VM guest OS and computer hardware. What i
VikaD [51]

The name of the operating system Jazmine is setting up is option A: Client  operating system.

<h3>What  is the operating system running in virtual machines?</h3>

A guest or client operating system is known to be the operating system that one can installed on a virtual machine (VM) or on any kind of partitioned disk.

Hence, the name of the operating system Jazmine is setting up is option A: Client  operating system.

Learn more about operating system from

brainly.com/question/22811693

#SPJ1

3 0
1 year ago
Write 4 types of viruses , explain them briefly.
wariber [46]

I can help with two.

Web Scripting Virus, A sneaky virus that targets popular websites. What this virus does is overwrite code on a website and insert links that can install malicious software on your device. Web scripting viruses can steal your cookies and use the information to post on your behalf on the infected website.

FILE INFECTOR, targeting executable files (.exe), file infector viruses slow down programs and damage system files when a user runs them.

8 0
2 years ago
. Write a function called is_sorted that takes a list as a parameter and returns True if the list is sorted in ascending order a
aalyn [17]

Answer:

There are multiple ways to solve the given problem, I will be presenting the most simple and easy way of solving this problem in few lines of code.

Python code:

def is_sorted(user_list):

   return user_list == sorted(user_list)

user_list=input("Please enter a list: ")

user_list = user_list.split()

print(is_sorted(user_list))

print("Your list: ", user_list)

Explanation:

A function is_sorted is created which takes a list as input and using the sorted() function of python which returns true when the list is sorted in ascending order and returns false when the list is not sorted in ascending order.

Driver code includes getting input list from the user and using split() function to create a list separated by space then printing the output of is_sorted function and in the last printing the contents of that list.

Output:

Please enter a list: 1 3 6 9

True

Your list:  ['1', '3', '6', '9']

Please enter a list: 15 7  2 20

False

Your list:  ['15', '7', '2', '20']

8 0
3 years ago
Using truth table, prove that:<br><br> (A + B). C = (A . C)+ (B .C) ?
Genrish500 [490]

Answer:

The image of truth table is attached.

Explanation:

In the truth table there is a separate table for the expression (A+B).C and for the expression (A.C)+(B.C) you can see in the truth table that the columns of (A+B).C is having same values as the (A.C)+(B.C).Hence we can conclude that (A+B).C is equal to (A.C)+(B.C).

4 0
3 years ago
Other questions:
  • System software falls into two categories: operating system software and ____ programs.â
    13·1 answer
  • Trojan Horse is a malicious program and a virus is a program. <br><br> a. True <br> b. False
    6·1 answer
  • In the space below, write the formula that needs to be added to the blank cells under the fourth column of the table.
    13·1 answer
  • Which of the following activities poses the greatest personal cybersecurity risk? A. Making a purchase on an online store that u
    13·1 answer
  • Drag each label to the correct location on the image.
    10·1 answer
  • Two technicians are discussing shielded cable. Technician A says that shielded wires are generally twisted in pairs to cancel th
    14·1 answer
  • People using commercially available software are usually asked to read and agree to a(n) _____
    10·1 answer
  • True or False? PPOs differ from HMOs because they do not accept capitation risk and enrollees who are willing to pay higher cost
    10·1 answer
  • List at least 5 professions for people working in the Information/Communication<br> fields.
    10·1 answer
  • A search expression entered in one search engine will yield the same results when entered in a different search engine.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!