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
Assoli18 [71]
2 years ago
13

Write a program that reads from the user any three points in two dimensional space: x1, y1, x2, y2, x3, y3. Assume these points

form a line segment, (x1, y1) to (x2, y2) to (x3, y3). Calculate the sum of these line segments and print value to two decimal places.For example with points (0.0, 0.0), (3.0, 4.0), (6.0, 8.0), the distance for the first segment is 5.0, the second segment is 5.0, so the output for this case would be 10.00. The input and output for this case would be:INPUT:0.0 0.03.0 4.06.0 8.0OUTPUT: 10.00
Computers and Technology
1 answer:
netineya [11]2 years ago
6 0

Answer:

The solution code is written in Python:

  1. import math  
  2. coord= input("Enter coordinates for three points: ")
  3. coordList = coord.split(" ")
  4. for i in range(0, len(coordList)):
  5.    coordList[i] = float(coordList[i])
  6. seg_1 = math.sqrt((coordList[0] - coordList[2])**2 + (coordList[1]- coordList[3])**2)
  7. seg_2 = math.sqrt((coordList[2] - coordList[4])**2 + (coordList[3]- coordList[5])**2)
  8. print(seg_1 + seg_2)

Explanation:

Firstly, we can use Python built-in method <em>input()</em> to get coordinates for three points from user (Line 3). To simplify the entry process, the input of the three coordinates is expected in a single string 0.0 0.0 3.0 4.0 6.0 8.0O. Please note each of the coordinates is separated by a single space.

Next, we can proceed to use Python string split() method and single space character " " as separator to break the input string of coordinates into a list of individual numbers ["0.0", "0.0", "3.0", "4.0", "6.0", "8.0"].

Prior to calculating the line segment, it is important to ensure the coordinates in the list,<em> coordList</em>, have been converted from string to float type (Line 6 - 7).

Next, we are ready to apply the Distance formula to calculate the length of the two line segments that join the three coordinates (Line 9 and Line 11).  The distance formula is \sqrt{ (x1 - x2){^2}  +  (y1 - y2){^2}   }

At last, sum up the two line segments, <em>seg_1 </em>& <em>seg_2 </em>and print it in the terminal (Line 13).

You might be interested in
Describe the role of the microprocessor in an automatic washing<br> machine (IGCSE)
Ann [662]
The microprocessor is programmed to follow the logic sequence of operation.

Monitoring various operator inputs, digital and analog inputs. Outputs to controlled devices take place.

Inputs: start switch, door safety contacts, water level sensor, wash cycle selector switch, etc.

Outputs: drive motor, motor speed regulation , reversing solenoids etc
3 0
2 years ago
In 5-10 sentences, describe the procedure for responding to an e-mail message.
miss Akunina [59]

Answer: See explanation

Explanation:

The procedure fur responding to an email message goes thus:

The first thing to do is to open the website of the email. Then, you would click on "compose".

When you click on compose, you'll see some space where you'll fill some information such as the email of the person that you're sending to, that is, the receiver. You'll also feel the subject of the email.

Then you type the content of your message. When you're done with this, then you click on send.

7 0
2 years ago
Perform depth-first search on each of the following graphs; whenever there's a choice of vertices, pick the one that is alphabet
Vikki [24]

Answer:

See the table attached for complete solution to the problem.

7 0
3 years ago
You are configuring a firewall to use NAT. In the configuration, you map a private IP address directly to a persistent public IP
Ivan

Answer:

Option B (Static NAT) would be the correct choice.

Explanation:

  • Static NAT seems to be a method of NAT methodology used to navigate as well as monitor internet usage from some kind of specific public IP address to something like a private IP address.
  • Everything always allows the provision of web access to technology, repositories including network equipment inside a protected LAN with an unauthorized IP address.

Some other decisions made aren't relevant to the situation in question. So the above alternative is indeed the right one.

8 0
2 years ago
A proper divisor of a positive integer $n$ is a positive integer $d &lt; n$ such that $d$ divides $n$ evenly, or alternatively i
juin [17]

Answer:

The program written in Python is as follows:

<em>See Explanation section for line by line explanation</em>

for n in range(100,1000):

     isum = 0

     for d in range(1,n):

           if n%d == 0:

                 isum += d

     if isum == n * 2:

           print(n)

Explanation:

The program only considers 3 digit numbers. hence the range of n is from 100 to 999

for n in range(100,1000):

This line initializes sum to 0

     isum = 0

This line is an iteration that stands as the divisor

     for d in range(1,n):

This line checks if a number, d can evenly divide n

           if n%d == 0:

If yes, the sum is updated

                 isum += d

This line checks if the current number n is a double-perfect number

     if isum == n * 2:

If yes, n is printed

           print(n)

<em>When the program is run, the displayed output is 120 and 672</em>

4 0
3 years ago
Other questions:
  • To include totals and other statistics at the bottom of a datasheet, click the ____ button on the HOME tab to include the Total
    12·1 answer
  • When seeking information on the internet about a variety of subjects, the most useful place to look would be
    8·2 answers
  • What is the penalty for refusing to submit to alcohol testing (drivers ed)
    7·2 answers
  • Gunther is filling in his own input mask. He wants to format the Social Security numbers of his clients. The field must contain
    5·1 answer
  • When configuring services, what linux directory typically contains server configuration files?
    8·1 answer
  • Jeanne writes a song, and Raul wants to perform
    6·2 answers
  • Kyle asked his supervisor which type of computing model was used when the enterprise first started. She explained that the organ
    14·1 answer
  • ..............................................................................
    8·1 answer
  • Which of the following statements about recommendation engines is TRUE?A: An online recommendation engine is a set of algorithms
    10·1 answer
  • Part of an algorithm which is repeated for fixed number of times is classified as.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!