Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this homework you will need to use the following: basic input and output, expressions, variables, and assignments, conditionals ( if / elif / else

For this homework you will need to use the following:
basic input and output,
expressions, variables, and assignments,
conditionals (if/elif/else), includes the use of nested conditional statements
loops (while / for)
Do not use any of the following language constructs (not an inclusive list): break and
continue statements, lists, tuples, sets, string methods, string formatting, and functions.
Question 2(hw4_q2.py): Write two versions of a program that reads a sequence of
positive integers from the user, calculates their geometric mean, and print the
geometric mean to four places. Each solution requires the use of loops (you choose
which one is appropriate).
Note: In mathematics, geometric mean of a dataset {a1,a2,a3,cdots,an} is given by
a1*a2*a3*...*ann. For example, the geometric mean of {2,9,12} is equal to 6
(2*9*123=6).
Your two versions of the program should read the integer sequence in two ways:
A. First read the length of the sequence followed by the sequence itself. For
example, an execution would look like:
B. Keep reading the numbers of the sequence until 'done' is entered by the user.
For example, an execution would look like:
Please enter a non-empty sequence of positive integers,
each one on a separate line. End your sequence by typing
done.
1
2
3
done
The geometric mean is: 1.8171
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions

Question

91 Risk management techniques.

Answered: 1 week ago

Question

Question 1 - Ch. 3 Problems - Co x + V X > C a...

Answered: 1 week ago