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 students of a college have to create their assignment reports using a word processing program. Some of the questions in thei
ser-zykov [4K]

Answer:

Table function

Explanation:

The table function can also be used to compare between items. The items can be arranged in columns and the features tonbe compared can be placed in columns. With this one can make comparison between the items.

5 0
3 years ago
Consider the following code example:
yKpoI14uk [10]

Answer:

The number of invoices for each vendor that have a larger balance due than the average balance due for all invoices.

Explanation:

This part of the code below

WHERE InvoiceTotal - PaymentTotal - CreditTotal >

(SELECT AVG (InvoiceTotal - PaymentTotal- CreditTotal)

FROM Invoices)

gives the condition to pick the invoices with balance that are greater than the average balance for all invoice.

This part of the code below

GROUP BY VendorName

ORDER BY BalanceDue DESC;

then enables the program to group the result of the above condition by VendorName and sort the resulting rows in the order of BalanceDue. You will therefore, obtain for each row in the NumberOfInvoices column, the number of invoices for each vendor that have a larger balance due than the average balance due for all invoices.

7 0
3 years ago
Let's get into some looping. Sometimes it is nice to generate your own data. Now let's take our first stab at it.
valkas [14]

Answer:

55

Explanation:

3 0
3 years ago
write a pseudo code that will allow a user to enter a number and divide that number by eleven and take the the modules of the en
emmasim [6.3K]

Answer:

sdhuvbfuisg

Explanation:

4 0
3 years ago
The first step in planning effective writing is to consider the _____. Audience Style Purpose Main Idea
spin [16.1K]

Answer:

The first step in planning effective writing is to consider your creativity

Explanation:

4 0
3 years ago
Other questions:
  • Can run mobile-style apps in the area known as the start screen, while running traditional software in the more familiar desktop
    6·1 answer
  • A collision volume is called ____
    7·1 answer
  • One of the attributes in a table in your database depends on another attribute for its meaning. What type of dependency has been
    14·1 answer
  • A custom information field that helps users to find a specific document is called
    8·2 answers
  • A column letter above the grid, also called the ____, identifies each column.
    9·1 answer
  • Password is an example of an authentication mechanisms that is based on " what an entity has".
    6·2 answers
  • Which technology has the potential to be misused to make atomic bombs? A. computer technology B. nuclear technology C. medical t
    14·1 answer
  • F he continues to make monthly payments of $100, and makes no new purchases, how many more payments will he have to make before
    13·1 answer
  • Public class Main{ public static void main(String [] args){ String name=WelcomeJava; Runnable r1=() -> System.out.println(nam
    12·1 answer
  • A programmer wants to determine whether a score is within 10 points of a given target. For example, if the target is 50, then th
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!