• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Oct 15th, 2019 104 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. #distance formula = on rubric
2. #ask user for xyz coordinates for 2 points
3. #call calc_distance function and send it to xyz coordinates
4. #returns back to main function using square root function in math mod
5.
6. import math
7.
8. #Ask the user for the x and y and z for 2 points
9. def main():
10.     x1 = float(input('Please enter an X coordinate for point 1: '))
11.     y1 = float(input('Please enter a Y coordinate for point 1: '))
12.     z1 = float(input('Please enter a Z coordinate for point 1: '))
13.     x2 = float(input('Please enter an X coordinate for point 2: '))
14.     y2 = float(input('Please enter a Y coordinate for point 2: '))
15.     z2 = float(input('Please enter a Z coordinate for point 2: '))
16.
17. #call function that calculates distance
18. def calc_distance(x1,y1,z1,x2,y2,z2):
19.     dist = math.sqrt((x2-x1)**2 +(y2-y1)**2 +(z2-z1)**2)
20.     return dist
21. #display distance to user
22.     print('The distance of the 2 points is', dist)
23.     print('This program will calculate the distance using square roots.')
24. #Call main function
25. main()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
Not a member of Pastebin yet?