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]
2 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]2 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
What career cluster does a fish and game warden fall in?
Andrej [43]
The answer is Law, Public safety, Corrections & Security career cluster.

This cluster is organized into several career paths that include emergency and fire management, Law enforcement services, legal and correction services. Fish and Game Wardens main tasks include, investigate hunting accidents or reporting of fish or game law violations and preserve native wildlife and ecosystems.





7 0
3 years ago
If you receive an increase in pay, how will that affect your payroll deductions?
spin [16.1K]
No it will actually help it
3 0
3 years ago
Write a function named replace_at_index that takes a string and an integer. The function should return a new string that is the
aalyn [17]

Answer:

def replace_at_index(str, number):

   new = str.replace(str[number], "-")

   return new

print(replace_at_index("eggplant", 3))

Explanation:

- Create a function called <em>replace_at_index</em> that takes a string and an integer

- Initialize a new variable called <em>new</em>, that will hold the new string

- Replace the character at given index with dash using <em>replace</em> function, it takes two parameters: the first is the character we want to replace, the second is the new character.

- Return the new string

- Call the function with the required inputs

4 0
2 years ago
What are the five generations of computer software​
Lerok [7]

Answer:

1st gen: Vacuum Tubes(1940–1956)

2nd gen: Transistors(1956–1963)

3rd gen: Integrated Circuits: (1964–1971)

4th gen: Microprocessors (1971–PRESENT)

5th gen: Artificial Intelligence (present)

Explanation:

8 0
2 years ago
Let G = (V, E) be an undirected graph. Design algorithms for the following (in each
Degger [83]

Answer:

i think its b if not sorry

Explanation:

3 0
2 years ago
Other questions:
  • Which connector is most commonly used to connect printers to desktop pc systems?
    10·1 answer
  • Correspondence involves verbal communication. True False
    6·2 answers
  • What do i study to become a network engineer?
    11·1 answer
  • Jeremy’s office is in an earthquake prone area. His web server is in his office. What step should he take to protect the data on
    5·1 answer
  • Within the Chart Design tab, which section is used to change the data of a previously created chart?
    12·1 answer
  • What are two advantages of encrypting data stored in the computer system?
    5·1 answer
  • When you use information hiding by selecting which properties and methods of a class to make public, you are assured that your d
    14·1 answer
  • Write a pseudocode statement that declares the variable total so it can hold integers. Initialize the variable with the value 0
    9·1 answer
  • 8. The cell reference for a range of cells that starts in cell A1 and goes over to column G and down to row 10 is, a. A1-G10 b.
    7·1 answer
  • Is a device used to test the network connection.
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!