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]
2 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]2 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
A block signature indicating that a text message was typed on a mobile device is an example of ____________.
Katarina [22]

A block signature indicating that a text message was typed on a mobile device is an example of  <u>impression management</u>.

The correct option is A.

<h3>What is  impression management?</h3>

Impression management is a conscious or unconscious process whereby individuals strive to regulate and control information in social interactions in order to affect how others perceive a person, an item, or an event.

<h3>What is the main goal of impression management?</h3>

The actions people take to influence others' perceptions of a notion are referred to as impression management. Depending on their objectives, people can work to reinforce existing beliefs or make an effort to change them.

<h3>What is block signature?</h3>

A signature block is the text that surrounds a signature and offers context for the signature as well as additional details. An email message, Usenet article, or forum post's signature block is a customized block of text that is automatically attached at the bottom of these types of documents.

To know more about  block signature visit:

brainly.com/question/2123747

#SPJ4

I understand that the question you are looking for is :

A block signature indicating that a text message was typed on a mobile device is an example of ____________.

A. impression management

B. convergence

C. evaluative language

D .pragmatic rules

6 0
2 years ago
Let's say that you handle the IT systems administration for your company. There's a server inside of your organization that chec
kirill115 [55]

From server do some file transfer to client PC to sync to the server.

<u>Explanation:</u>

As IT System administrator if PC or client or workstation or laptop not connected to network more than 3 months from windows server we need to refresh the connection and redo the connection from server to the client to do sync the activities.

Moreover from domain server refresh and re sync activities to establishing the connection.

Go to client PC or workstation or desktop login log and logout from the PC and login to domain account by changing the password.

7 0
2 years ago
The seven basic internal components found in a computer tower
Minchanka [31]
Motherboard, CPU, RAM, PSU, HDDs, GPU, and a Sound card.
8 0
3 years ago
Each time the enter key is pressed, word creates a new paragraph. (points : 2) true false
ludmilkaskok [199]
Your answer would be true
6 0
2 years ago
A user from the accounting department has contacted you regarding problems with a dot matrix printer. When you examine the outpu
Mama L [17]

Answer:

Replace the printhead is the correct answer.

Explanation:

Because in the following statement, that person is from the department of the accounting then, he call the technician regarding the problem occurs in the printer which is dot-matrix printer and when he examined the dot-matrix printer and replace the printhead because when he print any document then, he finds that some letters have missing from the page.

5 0
3 years ago
Other questions:
  • The layout button is located in the ____ group on the home tab?
    14·1 answer
  • The font color grid is located in the color group on the design tab. (points : 2) true false
    9·1 answer
  • What does mean I can’t turn on my computer and my computer won’t charge at all
    15·1 answer
  • Illustrator : how do you edit a swatch ?​
    12·1 answer
  • Robyn needs to ensure that a command she frequently uses is added to the Quick Access toolbar. This command is not found in the
    9·1 answer
  • The fractional_part function divides the numerator by the denominator, and returns just the fractional part.
    10·1 answer
  • A ______ is a group of slides designed and formatted for a specific purpose. These include themes as well as content.
    8·1 answer
  • What do you call the quality of information
    5·1 answer
  • Explain Http and Ftp​
    12·1 answer
  • What defines the scope of a project?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!