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
Alexandra [31]
3 years ago
7

Write a program that repeatedly takes integers from the user as long as he

Computers and Technology
1 answer:
Scorpion4ik [409]3 years ago
7 0

Answer:

Written in Python:

evens = 0

odds = 0

oddtotal = 0

eventotal = 0

total = 0

mylst = []

tryag = "Y"

while tryag == "Y" or tryag == "y":

     num = int(input("Input: "))

     mylst.append(num)

     tryag = input("Another Input (Y/y): ")

mylst.sort()

print("Minimum: "+str(mylst[0]))

print("Maximum: "+str(mylst[-1]))

for i in mylst:

     total = total + i

     if i%2 == 0:

           evens = evens + 1

           eventotal = eventotal + i

     else:

           odds = odds + 1

           oddtotal = oddtotal + i

print("Evens: "+str(evens))

print("Odds: "+str(odds))

print("Even Average: "+str(eventotal/evens))

print("Odd Average: "+str(oddtotal/odds))

print("Total Average: "+str(total/(evens+odds)))

Explanation:

The following lines initializes useful variables to 0

evens = 0

odds = 0

oddtotal = 0

eventotal = 0

total = 0

This declares an empty list

mylst = []

tryag = "Y"

This is repeated until user stops the loop by entering strings other than y or Y

while tryag == "Y" or tryag == "y":

This prompts user for input

     num = int(input("Input: "))

User input is appended to the list

     mylst.append(num)

This prompts user to try again the loop

     tryag = input("Another Input (Y/y): ")

This sorts the list from small to large

mylst.sort()

This prints 1. The minimum

print("Minimum: "+str(mylst[0]))

This prints 2. The maximum

print("Maximum: "+str(mylst[-1]))

The following iterates through the list

for i in mylst:

This calculates the total

     total = total + i

This checks for even entry

     if i%2 == 0:

This counts the number of even entries

           evens = evens + 1

This sums the even entries

           eventotal = eventotal + i

     else:

This counts the number of odd entries

           odds = odds + 1

This sums the odd entries

           oddtotal = oddtotal + i

This prints 3. Sum of Even entries

print("Evens: "+str(evens))

This prints 4. Sum of Odd entries

print("Odds: "+str(odds))

This prints 5. Average of Even entries

print("Even Average: "+str(eventotal/evens))

This prints 6. Average of Odd entries

print("Odd Average: "+str(oddtotal/odds))

This prints 7. Total Average

print("Total Average: "+str(total/(evens+odds)))

You might be interested in
What is Boolean algebra
VARVARA [1.3K]

Answer:In mathematics and mathematical logic, Boolean algebra is the branch of algebra in which the values of the variables are the truth values true and false, usually denoted 1 and 0, respectively.

Explanation:

4 0
3 years ago
Read 2 more answers
Calculate the total resistance of this simple circuit. If R1 = 100Ω, R2 = 200Ω.
andreyandreev [35.5K]

Answer: (66.7_1.8)Ω

Explanation: Hope it's helpful

3 0
2 years ago
What is a device driver?
ivann1987 [24]

The answer is A. Dude it shows a input device. It’s basically a disc driver

8 0
3 years ago
Read 2 more answers
When communicating with sockets, a client process initiates a request for a connection and is assigned a port by the host comput
melamori03 [73]

Answer:

D. 80

Explanation:

By default, the port number for a web server is 80.

3 0
4 years ago
Read 2 more answers
In a(n) ____________________ device, the movement of electrons performs essentially the same functions as gears and wheels in me
lana66690 [7]

Answer:

Electronic computing.

Explanation:

8 0
2 years ago
Other questions:
  • Whoevr answers this will be marked brainliest
    12·1 answer
  • 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
    6·1 answer
  • You have configured a LAN with 25 workstations, three network printers, andtwo servers. The workstations and printers will have
    9·1 answer
  • A client contacted you to request your help in researching and supplying the hardware necessary to implement a SOHO solution at
    5·1 answer
  • Jeremy is working with a team that is creating an application using attributes and associated methods. What type of programming
    8·1 answer
  • What is wrong with a MOV BL, CX instruction?
    6·1 answer
  • Which type of protocol allows for a secure data transmission using encryption methods?
    7·1 answer
  • 2.3 Code Practice: Question 1
    5·1 answer
  • Chloe is creating the software requirements specifications (SRS) for a project. The project is a web app that allows students to
    12·1 answer
  • after adding a sound to a slide, the audio tools tab will allow you to apply artistic effects and quick styles to your sound ico
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!