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
How can I crack a computer password?
Irina18 [472]
Try to use easy passwords first like the persons birthday fav color etc then move on to harder passwords
7 0
3 years ago
If a product can be made and used for a long time into the future, that product is
Ksivusya [100]
I believe it is That product is sustainable.
8 0
3 years ago
What is similar software engineering, Hardware engineer, Network Architect, and Web developer?
Oliga [24]

I Am Pretty Sure The Answer Is - "B"

Hope This Help's

5 0
3 years ago
Which of the following can you not code in a subclass? Select one: a. a method with the same signature as a method in the superc
Ray Of Light [21]
<h2>Option D: a call to a private method of the superclass</h2>

Explanation:

Option a: a method with the "same signature" is allowed in the subclass. There will not be any confusion because the object which is trying to call the method will decide whether to call the sub class or super class.

Option b: a call to a super class constructor is possible because, when you create an object of sub class automatically the super class constructor will be called. Even the sub class constructor can call the super class constructor explicitly.

Option c: A subclass can create method that's not defined by the super class

Option D: a private method is private inside the class and hence even the object of that class cannot access.

8 0
3 years ago
19 dollar fortnite gift card
Ann [662]
Who wants it? ........
3 0
3 years ago
Read 2 more answers
Other questions:
  • Television broadcasts were originally delivered by using which technology
    14·1 answer
  • In Microsoft Excel, you have a large dataset that will print on several pages. You want to ensure that related records print on
    13·1 answer
  • When looking to attract a local audience, why it is important to optimise your website and content for mobile users?
    12·1 answer
  • If you had the choice to pick one car in the world for free.. what car would you
    10·1 answer
  • python Consider this data sequence: "3 11 5 5 5 2 4 6 6 7 3 -8". Any value that is the same as the immediately preceding value i
    7·1 answer
  • How Do I Make A Walk animation for a school Project?? Gifs?
    13·1 answer
  • Lists and Procedures Pseudocode Practice For each situation, provide a pseudocoded algorithm that would accomplish the task. Mak
    8·1 answer
  • Select the correct answer.
    9·1 answer
  • Modify the solution to PP 11.1 such that it catches and handles the exception if it is thrown. Handle the exception by printing
    5·1 answer
  • To avoid legal issues and set clear guidelines and expectations for employees, employers should put which of the following in pl
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!