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 is NOT a factor that increases the health risks of construction workers?
Nadya [2.5K]

From all the available options, the one that would not increase the health risk for construction workers would be (D) stable, rarely changing job site environments and conditions.

High number of unskilled labors increase the likelihood that an accident might occur, while high turnover creates instability which in turn might increase the same likelihood due to increased workload while human resources seek a replacement. Multiple contractors and subcontractors mean confusions might arise and accident may likely happen if the risk is not properly managed.

8 0
3 years ago
Read 2 more answers
PowerPoint Online automatically saves your presentation to what Office Online application? OneDocument OneDrive OneNote OneWay
-BARSIC- [3]

Answer:

OneDrive

Explanation:

OneDrive is Microsoft cloud storage service. so it makes sense it would save it their :)

6 0
3 years ago
Read 2 more answers
Im confused sorry.. can i get help?
garik1379 [7]

1.

If-then statements are used in a program to run certain code when ideal conditions are met.

2.

Since the variable word holds the word kangaroo and the if statement is asking if the variable word is equal to KANGAROO, the else statement will run. The output will be FALSE

3.

if (90 < = x <= 100) should be rewritten as Nothing, the if statement is correct.

4.

You use an else statement when you want your code to do something if your if statement is false.

5.

if (num1 != num2)

I hope this helps!

7 0
3 years ago
Suppose there are 69 packets entering a queue at the same time. Each packet is of size 7 MiB. The link transmission rate is 1.7
svp [43]

Answer:

69.08265412 milliseconds

Explanation:

Lets first convert 7 MiB to bits

7*1024*1024*8=58720256 bits

Now convert bits to Gbits

58720256/10^{9}  =0.058720256 Gbits

Queuing Delay = Total size/transmission link rate

Queuing Delay= \frac{0.058720256}{1.7} =0.03454132706 seconds

Delay of packet number 3 = 0.03454132706*2=0.06908265412 seconds

or 0.06908265412= 69.08265412 milliseconds

7 0
4 years ago
A(an) _______ is a set of instructions that a computer follows to perform a task.
Vikentia [17]
A(an) _______ is a set of instructions that a computer follows to perform a task.Answer is Program .
I hope the answer of the question.
7 0
4 years ago
Other questions:
  • Write a method isSorted that returns true if the list is in sorted (nondecreasing) order and returns false otherwise. An empty l
    12·1 answer
  • The syntax used for referencing cells with their worksheet names is the sheet name, followed by ____, then the usual column lett
    8·1 answer
  • Which vpn protocol is a poor choice for high-performance networks with many hosts due to vulnerabilities in ms-chap?
    15·1 answer
  • The status bar only lets you view the current X, Y and Z coordinates of the cursor. Select one: True False
    8·2 answers
  • /* Write a method called fractionSum that accepts an integer parameter n and
    5·1 answer
  • You want to read input from the user to know how many apples they would like
    10·1 answer
  • A major retailer wants to enhance their customer experience and reduce losses
    6·1 answer
  • please help me out i’ll give you brainlist
    14·1 answer
  • A _______ is a group of elements that you want to style in a particular way.
    8·2 answers
  • Which protocol is often used in conjunction with ipsec to provide a remote access client vpn with user authentication?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!