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]
3 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]3 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
What is the maximum number of communication paths for a team of twenty people?
MAVERICK [17]
Each of the 20 people has 19 other people to communicate to. If you add that all up you get 20*19 paths, but then each path is counted twice (back and forth), so we divide this by 2. 20*19/2 = 190.

The general forumula is n(n-1)/2
6 0
3 years ago
What phrase indicates someone has knowledge and understanding of computer,internet,mobile devices and related technologies?
navik [9.2K]

Digital literacy is the term for having knowledge of computers, internet, mobile devices and related technologies.

7 0
3 years ago
You can place an insertion point by clicking in the field or by pressing ____.
Slav-nsk [51]
You can place an insertion point by clicking in the field or by clicking F2 keyboard shortcut. Insertion point is usually characterized by a blinking vertical line that allows you to insert a next character that you wanted.
4 0
3 years ago
What is the difference between a syntax error and a logical error?
RoseWind [281]
A syntax error can be a simple mistake as a typo or an extra space. A logical error has to do with the code structure, and if it makes sense.

Hope this helps!
5 0
3 years ago
Need answer ASAP
kaheart [24]

Answer:

D. To ensure that the software adheres to technical standards

Explanation:

The responsibility of the software architect is to ensure that all parts of the software system are able to meet the requirements set forth by the project or specifications, in this case, the technical standards.  This is an important piece of the software system because without it, the software system may not perform the necessary functions that it was written to do.

Cheers.

5 0
2 years ago
Other questions:
  • Problems with using a single Local Area Network (LAN) to interconnect devices on a premise include ______.
    12·1 answer
  • A function operates on this, which may consist of a constant, a cell reference, or another function.
    7·1 answer
  • Markup is best defined as
    11·1 answer
  • How many address bits are needed to specify each byte in a 512 byte memory unit?
    5·1 answer
  • What is the full form of icimod?
    6·1 answer
  • Ali is in the hospital about to undergo a brain-imaging process that involves taking many x-rays from different angles aided by
    9·1 answer
  • PLEASE HELP! I'm offering brainliest!
    6·1 answer
  • Write a Java program that has a static method named range that takes an array of integers as a parameter and returns the range o
    10·1 answer
  • Why are iterators useful?
    8·1 answer
  • How media platform drives globalization.<br> Advantages and disadvantages of using media platforms?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!