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
Which of the following statements are true regarding models? Select 3 options.
IrinaVladis [17]

Answer:

Models represent the system or problem at a detailed implementation level.

Models help communicate a design.

Models help you understand a complex situation by including all of the details.

hope this is correct :)

6 0
2 years ago
The register in the CPU is not the same as the RAM.
omeli [17]
The answer is true ..........
5 0
3 years ago
Groups to which we belong are defined late in our development true or false
Anna71 [15]
The answer is false......
7 0
3 years ago
Which of these is the term for a result that is not expected or intended?
jarptica [38.1K]
No options. Well it would be a surprise.
5 0
3 years ago
A technician discovers an Ethernet cable needs to be rewired. The RJ-45 connector has been pulled off. What is the next step in
Oxana [17]
Re seal the connector
8 0
3 years ago
Other questions:
  • System design is the determination of the overall system architecture-consisting of a set of physical processing components, ___
    6·2 answers
  • 100 POINTS NEED ASAP PLEASE HELP
    8·2 answers
  • The two ways to use the help menu is by searching of the contents or searching the _____
    13·2 answers
  • What is the difference between a key escrow and a recovery agent? (Choose all that apply.)
    12·1 answer
  • What tasks do most operating systems perform?
    15·1 answer
  • Josephine is in the process of creating ads within her Standard Display campaign. She finds that there are two main ad formats t
    15·1 answer
  • When Kim was working in her Microsoft® Excel® spreadsheet, she accidentally placed her book on the spacebar and erased the conte
    13·1 answer
  • Enhancement of job satisfaction and productivity are key characteristics of which theoretical perspective of work design? ​
    6·1 answer
  • Greedy Algorithm Design
    8·1 answer
  • How do big organizations take back their data to be reviewed after a disaster?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!