QUESTION IMAGE
Question
challenge activity 2.9.2: using math functions to calculate the distance between two points. organize the correct code statements to find the distance between point (x1, y1) and point (x2, y2), and assign the result to points_distance. the calculation is: distance = \sqrt{(x2 - x1)^2 + (y2 - y1)^2} note: not all code statements on the left should be used in the final solution. how to use this tool unused y_dist = math.pow((y2 - y1), 2) x_dist = math.pow((x2 - x1), 2) main.py import math x1 = float(input()) y1 = float(input()) x2 = float(input()) y2 = float(input()) x_dist = math.pow((x1 - y1), 2) print(points_distance) points_distance = math.sqrt(x_dist + y_dist) y_dist = math.pow((x2 - y2), 2)
Step1: Fix x distance calculation
Replace incorrect x_dist = math.pow((x1 - y1), 2) with x_dist = math.pow((x2 - x1), 2)
Step2: Fix y distance calculation
Replace incorrect y_dist = math.pow((x2 - y2), 2) with y_dist = math.pow((y2 - y1), 2)
Step3: Reorder calculation and print
Move points_distance = math.sqrt(x_dist + y_dist) before print(points_distance)
Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
The corrected full code is:
import math
x1 = float(input())
y1 = float(input())
x2 = float(input())
y2 = float(input())
x_dist = math.pow((x2 - x1), 2)
y_dist = math.pow((y2 - y1), 2)
points_distance = math.sqrt(x_dist + y_dist)
print(points_distance)
The unused code statements are:x_dist = math.pow((x1 - y1), 2)y_dist = math.pow((x2 - y2), 2)