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
Your sister is starting 9th grade next year and is thinking about going to college. What step would you recommend she take first
lozanna [386]

think about what she wants to do with her life and what collage is best fit for that


5 0
3 years ago
Read 2 more answers
The true or false questions.<br><br> 1.egrep can accept multiple filenames as input arguments.
BlackZzzverrR [31]

Answer: True  

Explanation: yes, it is true that egrep can accept multiple filenames as input arguments for example egrep -r "text1/text2", so this will search in all the sub directories . E grep is also known as 'grep -E' which belongs to the group of grep function and we used egrep to separate multiple patterns for OR conditions. This is also very less time consuming if you are going to search multiple input arguments in multiple different logs at the same time.

5 0
3 years ago
There are a number of roles held by various users of online digital media, including contributors, conversationalists,
Maru [420]

Answer:

The mass media is a huge phenomenon. Through the various different platforms, print or broadcast, the media is able to reach millions of people like no other force. Without the media, powerful speeches by politicians would affect no one, local events would remain local, and performances by great actors would be seen only by the people in the immediate audience. The media overcomes distances, and builds a direct relationship with the audience. Many sociologist

4 0
3 years ago
Read 2 more answers
Which of the following statements Terminates the program andstops all threads?
Law Incorporation [45]

Answer:

(c) system.exist(1);

Explanation:

system.exist(1); is used for the termination of the program here both option c and d should be correct but in option d there is exit(0) and zero indicates return means program will return but besides zero if there is any non zero number then program will not return and in option c there is a non zero number which means program will not return so option c  system.exist(1); will be the correct option for the termination of program

8 0
3 years ago
True or false
ICE Princess25 [194]
1. True
2. Usually true, but it depends on the search engine you're using.  For example, Google lets you search for several words without commas.
3 0
3 years ago
Other questions:
  • In the database below, the arrow is pointing to a _____.<br> file<br> record<br> field<br> key field
    12·1 answer
  • . Java is a high-level language.. true or false?
    5·1 answer
  • What does Verizon child allow parents to do? My parents recently got the app and put it on my phone so I was wondering...
    11·1 answer
  • Why is it important to know who reviews the information posted on a Web site?​
    15·1 answer
  • Write a function "nonRepeatings" that takes a string "s3" and returns the non-repeating characters in this string. Sample Input
    11·1 answer
  • What statement should you use to print the value of total with a precision of 5 digits?
    7·1 answer
  • Which statement describes one drive?
    6·1 answer
  • Why can’t I “change the country” on settings??<br> (In this app)
    13·1 answer
  • Aside from human user types, there are non human user groups. Known as account types, __________ are implemented by the system t
    10·1 answer
  • Silas develops this algorithm to compute the calories burned for an activity for a given number of minutes and body weight: If t
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!