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
PSYCHO15rus [73]
3 years ago
12

Write a program that calculates the average of N integers. The program should prompt the

Computers and Technology
1 answer:
r-ruslan [8.4K]3 years ago
5 0

Answer:

def Average(num):

   if num == 0:

       return 0

   val = 0

   trueNum = num

   for i in range(0, num):

       try:

           val += int(input("Enter value (%d out of %d): " % (i+1,num)))

       except Exception as e:

           print ("Error processing value. Non integer detected.")

           try:

               val += int(input("Enter value (%d out of %d): " % (i+1,num)))

           except Exception as e:

               print ("Error processing value. Non integer detected.")

               print ("OMITTING value from average.")

               trueNum -= 1

   return val/trueNum

def main():

   try:

       num = int(input("Enter a value N for amount of items: "))

       if num < 0:

           raise(ValueError)

   except ValueError:

       print ("N must be positive integer.")

       exit(1)

   print("Average: ", Average(num))

   exit(0)

if __name__ == "__main__":

   main()

Explanation:

This program is written in Python to collect some integer value from the user as an upper bound of integers to be input for an average.  Using this upper bound, the program checks to validate it is indeed an integer.  If it not an integer, then the program alerts the user and terminates.  If it is a user, the Average function is called to begin calculation.  Inside the Average function, the user is prompted for an integer value repeatedly up until the upper bound.  Using the sum of these values, the program calculates the average.  If the user inputs a non integer value, the program will alert the user that the value must be an integer and ask again.  If the user again inputs a non integer value, that iteration will be omitted from the final average.  The program this prints the calculated average to the user.

Cheers.

You might be interested in
H&amp;R Block's stated purpose is: to be the leading global consumer tax company bringing tax and related solutions to clients y
jok3333 [9.3K]

Answer:

The correct answer is D.

Explanation:

In the given example, the task that the artificial intelligence system has to fulfill is to take control of an irregular task that is performed by humans. This requires a solution that depends on neural networks which work by evaluating given data sets and makes sense of them through the provided algorithms. They eventually come to a conclusion recognizing the relationships between the data points so that the system can decide what action to take. This procedure can be implemented to take control of the tax solution task that is performed by accountants.

I hope this answer helps.

5 0
3 years ago
An app builder has created a report for sales people to view records from the custom object, some users have complained that the
a_sh-v [17]

Answer:

Check sharing rules

Check organization-wide defaults

Check the user s profile for object settings

Explanation:

There is a need for some people to see the total transparency of the records that are meant to be shared with a select group of people. There are certain things that can be done for this. The first one is that the sharing rules should be checked. To whom are the details shared with. The next one is the filters that are used.

These can be reported and changed accordingly. Lastly, the whole organization’s defaults can be checked. This is something that can be done when the previous methods that were done did not work that well. Once some changes are done, the people can check if they already work and if the records can be viewed.

6 0
4 years ago
PLEASE HELP ASAP!!!!111 Read "Teenagers are rewriting the rules of the news" (find it somewhere and answer questions below)
Ilya [14]

Answer:

Sorry, we picked up your question late. There are a lot of questions, and every now and then some misses out. And I am sure you will understand. However, the cool thing is your answers are correct. I read the complete article on young adults or teenagers and found the same. And I am sure you will agree with the facts, and use its best meaning in your own life. I am, however, listing below all the answers for your complete satisfaction. And I congratulate you, you are up with the correct list of answers.

The answer to the First question is:

B. the description of how influencers follow young social media users"

Second question answer is

C. Andrew Yang

And the third question answer is:

C. Teens and young adults consume and spread news information through social media.

And I am sure you must have liked this article. Article reading is a good habit. You should always start a day by reading one article online or in newspaper.

Explanation:

Please check the answer section.+

4 0
3 years ago
A potential threat to administrators’ ability to manage the correctional system is
OlgaM077 [116]
(privatization) is your answer to this question you are asking 
4 0
3 years ago
You have just taken over management of a server on which the previous server administrator has set up several server components,
Arisa [49]

Answer:

d. Ensure file caching and flushing are enabled for all disk drives.

Explanation:

When the disk reading and writing is delayed and the server performance is also slow after taking over management of a server.Previously the server has several server components.So to increase the performance we should ensure caching of the file and make sure that the flushing is enabled for all disk drives.Hence the answer to this question is option d.

8 0
3 years ago
Other questions:
  • Which of the following allows you to view and access important information about your document all in one location?
    14·1 answer
  • Operating systems that have windows and icons have which type of user interface?
    15·1 answer
  •   Why does a shaded-pole motor run at a constant speed?  A. The lines of force do not change direction.  B. The current through
    15·1 answer
  • ou have spent the last two hours creating a report in a file and afterwards you use cat to create a new file. Unfortunately the
    13·1 answer
  • One way that Intuit handles the ________ of its TurboTax and other financial software is through its websites. The site includes
    11·2 answers
  • The following code in a different program is not working properly.The message should display the value of the intCounter variabl
    11·1 answer
  • Help me please .<br>and thank you ..​
    14·1 answer
  • Draw a flowchart diagram for a program that display a person's name x times​
    5·1 answer
  • A manufacturing company has decided to be carbon free by 2030. What can it do to achieve this goal?.
    7·1 answer
  • Your friend Cameron’s little sister is visually impaired. Cameron is worried that his sister will not be able to use technology
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!