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
Anettt [7]
3 years ago
13

Write two versions of a program that reads a sequence of positive integers from the user, calculates their geometric mean, and p

rint the geometric mean. Note: In mathematics, geometric mean of a dataset {a1, a2, a3 ..., an} is given by: a1 For example, the geometric mean of 2,9 and 12 is equal to 6 (V2 -9 12 = Your two versions of the program should read the integer sequence in two ways:
a) First read the length of the sequence For example, an execution would look like: Please enter the length of the sequence: 3 Please enter your sequence: a2 a3 an 6). 1 2 3 The geometric mean is: 1.8171
b) Keep reading the numbers until 'done' is entered. For example, an execution would look like: Please enter a non-empty sequence of positive integers, each one in a separate line. End your sequence by typing done: 1 2 3 done The geometric mean is: 1.8171
Computers and Technology
1 answer:
givi [52]3 years ago
4 0

Answer:

1)

n = int(input("Please enter the length of the sequence: "))

print("Please enter your sequence")

product = 1

for i in range(n):

   val = int(input())

   product *= val

print("The geometric mean is: %.4f"%pow(product,1/n))

2)

print("Please enter a non-empty sequence of positive integers, each one is in a separate line. End your sequence by typing done:")

product = 1

val = input()

n = 0

while(val!="done"):

   product *= int(val)

   n += 1

   val = input()

print("The geometric mean is: %.4f"%pow(product,1/n))

Explanation:

You might be interested in
The object-oriented techniques to manage errors such as dividing a value by 0 comprise the group of methods known as
charle [14.2K]
The object - oriented techniques to manage errors such as dividing a value by 0 comprise the group of methods known as Error handling. Error handling is managing the mistakes made on any type of scenario. This skill is needed to all IT and Computer Science majors.
6 0
4 years ago
The area where a blast originates is referred to what perimeter/isolation zone
Anna [14]
The area where a blast originate from is referred to as PERIMETER. After a bomb blast incident, the first responders has to map out a safe pre-blast perimeter based on the requirements of Bureau of Alcohol, Tobacco, Firearms and Explosives [BATFE]. After this, the first inner perimeter, also called hot zone must be established. This is where the blast originated from and it is the point where victims rescue and treatment will start.
8 0
3 years ago
What is the importance of the query object why do we need such an object?
Firlakuza [10]

Answer:

Business Central query objects enable you to retrieve records from one or more tables and then combine the data into rows and columns in a single dataset. Query objects can also perform calculations on data, such finding the sum or average of all values in a column of the dataset.

6 0
4 years ago
It's so eazy
Dmitrij [34]

Answer:

  1. true
  2. true
  3. false
  4. true
  5. true
4 0
3 years ago
Read 2 more answers
James, a system administrator, is tasked to update the BIOS and firmware of the computer in his organization. What are the reaso
Xelga [282]

Answer:

One reason to update BIOS and firmware is to ensure they support new hardware like CPU model or graphic card. In some cases, the updates can also resolve overheating issue or motherboard issue.  

However, this is not always the case that we must update the BIOS every time there is a new release because the latest update may cause problem to existing system as well.

As a general rule, only when there are some problems with the existing BIOS and firmware, we are only required to update them.

7 0
3 years ago
Other questions:
  • Marie can now edit her photos, send them in emails, print them on a printer, and use them as wallpaper on her computer. This is
    9·2 answers
  • Members of which generation were born after the turn of the millennium?
    11·1 answer
  • _______________________ is a short-term program, typically 30 hours long, in which a therapist, social worker, or trained probat
    5·1 answer
  • Design and implement a java program (name it CheckPoint) that prompts the user to enter the x-coordinate and y-coordinate of a p
    6·1 answer
  • Rock, Paper, Scissors is a two-player game in which each player chooses one of three items. If both players choose the same item
    9·1 answer
  • Many Web browsers allow users to open anonymous windows. During a browsing session in an anonymous window, the browser does not
    14·1 answer
  • 4.2.10: Multiplication Table: Create a program using a for loop which will print out the 4’s times table through 10.
    9·1 answer
  • How many parts make up a web address? One To Three​
    6·1 answer
  • It is the responsibility of a manager to understand the company’s IT architecture and corresponding infrastructure so that the
    8·1 answer
  • What's the difference between an exe file and an msi file?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!