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
When assembling a desktop computer you should always install the drives before the motherboard?
s2008m [1.1K]
Yes you should install drives first
8 0
3 years ago
The following memo does not follow the correct format. What should be changed? To: Stacy, Allen, and Emma Date: August 12, 2012
miss Akunina [59]
<span>The From: line should appear under the To: line.

</span>
4 0
3 years ago
Read 2 more answers
Predictive coding software leverages .............................when experts review a subset of documents to teach the softwar
pantera1 [17]

Answer:

A.Human analysis, documents

Explanation:

Predictive coding in softwares is artificial intelligence that works by automating document review. This involves training software with data from "subset of documents" to be generally applied(apply same logic) to a larger group of documents. This is employed by a large group of technologists to ease the task of manually reviewing a huge set of documents.

7 0
3 years ago
Which of the following sentences is written in the active voice
STALIN [3.7K]
D. The chocolate cake will be served to the queen. This is the only one not in past tense. Active means present or near present, hence the word "will." 
3 0
3 years ago
Read 2 more answers
You’ve been hired to help a bank automate their deposit/withdrawal system! Your task is to write a Python program that interacts
mixer [17]

Answer: See below

Explanation:

<u>Description:</u> In this program, read-option from the user and based on that, perform the operation. And display the balance if the balance is negative.

<u>transactions.py</u>

balance = 1000

#read options from the user

option = input("Deposit or withdrawal: ")

amount = 0

#check if option is a withdrawal

if option == 'withdrawal':

amount = int(input("Enter an amount: "))

balance = balance - amount

#check option is deposit

elif option == 'deposit':

amount = int(input("Enter an amount: "))

balance = balance + amount

else:

print("Invalid transaction.")

#check balance is less than 0 (negative)

if balance < 0:

print("You cannot have a negative balance!")

else:

print("Final balance:",balance)

4 0
2 years ago
Other questions:
  • In microsoft windows when a window is minimized what happens to that window
    9·1 answer
  • How can a wiki contribute to an academic paper?
    9·2 answers
  • Put the steps of the decision-making process in the correct order.
    12·1 answer
  • For this lab, you will work on a simple GUI application. The starting point for your work consists of four files (TextCollage, D
    5·1 answer
  • Which port must be open on your router to allow you to upload device configuration and firmware updates using trivial file trans
    13·1 answer
  • Which of the following variable names is not valid? 1price 1 price price 1 price1
    15·2 answers
  • The MAA is responsible on a daily basis to protect office computers and patient records and personal information from hackers. R
    12·1 answer
  • What key should i press to leave the cell as it orginally was
    9·1 answer
  • Que es un vlog? Cual es la diferencia entre vloc y papgina web? ​
    7·1 answer
  • What are your undertale + au ships?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!