Write a python program to calculate distance between two points taking input from the user.

preview_player
Показать описание
Rajasthan Technical University B.Tech (CSE-VI Sem) Python Lab
Experiment-2.1: Write a python program to calculate distance between two points taking input from the user .
Рекомендации по теме
Комментарии
Автор

def menu():
print("[1] Distance between 2 coordinates")
print("[2] Area of triangle by 3 coordinates")
print("[3] Section formula")
print("[0] Exit the program.")


menu()
option = int(input("Enter your option: "))

while option != 0:
if option == 1:
print("Option 1 has been called.")
print("To find distance the formula is = ((X2-X1)*(X2-X1) + (Y2-Y1)*(Y2-Y1))")
X1 = int(input("Enter No. X1:"))
X2 = int(input("Enter No. X2:"))
Y1 = int(input("Enter No. Y1:"))
Y2 = int(input("Enter No. Y2:"))
distance = ((X2-X1)*(X2-X1) + (Y2-Y1)*(Y2-Y1))

result = distance**0.5

print("distance =", result)
print("Thx for using this programme")

elif option == 2:
print("Option 2 has been called.")
print("To find area the formula is =
X1 = int(input("Enter No. X1:"))
X2 = int(input("Enter No. X2:"))
X3 = int(input("Enter No. X3:"))
Y1 = int(input("Enter No. Y1:"))
Y2 = int(input("Enter No. Y2:"))
Y3 = int(input("Enter No. Y3:"))

area =
print("Area =", area)
print("Thx for using this programme")


if option == 3:
print("Option 3 has been called.")
print("To find the point dividing the line formula is = ((M*X2 + N*X1)/(M + N), (M*Y2 + N*Y1)/(M + N))")
M = int(input("Enter No. M:"))
N = int(input("Enter No. N:"))
X1 = int(input("Enter No. X1:"))
X2 = int(input("Enter No. X2:"))
Y1 = int(input("Enter No. Y1:"))
Y2 = int(input("Enter No. Y2:"))
Answer = ((M*X2 + N*X1)/(M + N), (M*Y2 + N*Y1)/(M + N))
print("Answer is:", Answer)
print("Thx for using this programme")

else:
print("Invalid option.")

print()
menu()
option = int(input("Enter your option: "))




print("Thanks for using this prgram")

mastergamer-zqxc
Автор

how do you programmed |x1 − x2| + |y1 − y2| ?

storm-
welcome to shbcf.ru