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
Software is nothing but a piece of code or set of instructions written in a chip to run a hardware device on the Computer. O Tru
yarga [219]

Answer:

True

Explanation:

Because it is a database that have not been process as information

5 0
4 years ago
You are adding a new 500 GB hard drive to your computer. The hard drive must be formatted with a file system to organize files i
AURORKA [14]
<h2>Answer:</h2><h3>NTFS is recommended according to given scenario.</h3>

<h2>Explanation:</h2>

Following are some point that help you understand the term NTFS:

  • NTFS is abbreviation of New Technology File System.
  • It is a file system that is commonly used in Windows Operating system now a days. Today's computers use NTFS widely.
  • Files are stored and retrieved on hard drive by means of the NTFS.
  • NTFS is somehow an advanced version o FAT(File allocation Table) and HPFS.
  • NTFS is adopted as it is extendtable as well as secure.

<h3>I hope it will help you!</h3>
3 0
3 years ago
mary has access to certain resources because she is in the Research division of her company. She has access to other resources b
Gemiola [76]

Answer:

KeyCards

Explanation:

Keycards are able to be stacked with alot of roles

im sorry if im wrong

3 0
3 years ago
Two boxes overlap if their interiors have at least one point in common. Give an O(n log n)-time algorithm that decides if there
GaryK [48]

Answer:

// Program is written in C++ programming language

// The program checks if two boxes overlap and prints both boxes

// Comments are used for explanatory purpose

// Program starts here

#include<bits/stdc++.h>

#include <graphics.h>

#include <conio.h>

// Define x and y axis

struct axis { int x, y; };

bool checkRect(Axis l1, Axis r1, Axis l2, Axis r2)

{ // l1, l2, r1 and r2 represent the left and right coordinates of both rectangles

// Check one rectangle is on left side of other

if (l1.x > r2.x || l2.x > r1.x) {

return false; }

// Check if one rectangle is above other

if (l1.y < r2.y || l2.y < r1.y) {

return false; }

return true;

}

// Main Method begins here

int main()

{

// Declare integer variables to enter rectangle coordinates

// For rectangle 1

int left1, left2, right1, right2;

cout<<"Enter First rectangle coordinates: "<<"\n";

cout<<"Top Left: "<<"\n";

cin>>left1;

cout<<"Bottom Left: "<<"\n";

cin>>left2;

cout<<"Top Right: "<<"\n";

cin>>right1;

cout<<"Bottom Right: "<<"\n";

cin>>right2;

// For rectangle 2

int left3, left4, right3, right4;

cout<<"Enter Second rectangle coordinates: "<<"\n";

cout<<"Top Left: "<<"\n";

cin>>left3;

cout<<"Bottom Left: "<<"\n";

cin>>left4;

cout<<"Top Right: "<<"\n";

cin>>right3;

cout<<"Bottom Right: "<<"\n";

cin>>right4;

Axis l1 = {left1, left2}, r1 = {right1, right2};

Axis l2 = {left3, left4}, r2 = {right3, right4};

if (checkRect(l1, r1, l2, r2)) {

cout<<"The Rectangles Overlap"; }

else {

cout<<"Rectangles Don't Overlap";}

// Print Rectangle 1

rectangle (left1, right1, left2, right2);

// Print Rectangle 2

rectangle (left3, right3, left4, right4);

return 0;

}

5 0
3 years ago
When converting text to a table, which feature should be used?
velikii [3]
I’m pretty sure it would be an insert tab
4 0
3 years ago
Other questions:
  • The most effective way to perform data entry is to keep your hands on the keyboard and press to move to the text cell in the row
    10·1 answer
  • In what ways us cyberspace is real? list at least 3 examples to support your response .
    9·1 answer
  • A network administrator is using packet tracer to mock up a network that includes iot devices. What can the administrator do fro
    15·1 answer
  • Write a pseudocode that will take marks of physics, chemistry and math as input, calculates the average and displays output.
    7·2 answers
  • An F-1 ____________ may be authorized by the DSO to participate in a curricular practical training program that is an__________
    8·1 answer
  • Write an application named Perfect that displays every perfect number from 1 through 10,000. A number is perfect if it equals th
    5·1 answer
  • You are asked to check your company’s configurations to determine if any filters should be built to stop certain ICMPv6 traffic.
    9·1 answer
  • Which are aspects of the post-production stage?
    9·1 answer
  • Gn guys have an Amazing day!
    12·2 answers
  • Describe some things that this person might say that might cause you to NOT hire them. Explain.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!