Upload files to "basic programming/1st task"

This commit is contained in:
2024-11-23 15:48:40 +02:00
parent b4ef6ebbac
commit a3e834c190
5 changed files with 90 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
# Q10
# Imports
import math
# Get values from user
x1 = float(input("Enter x-coordinate for point 1: "))
y1 = float(input("Enter y-coordinate for point 1: "))
x2 = float(input("Enter x-coordinate for point 2: "))
y2 = float(input("Enter y-coordinate for point 2: "))
x3 = float(input("Enter x-coordinate for point 3: "))
y3 = float(input("Enter y-coordinate for point 3: "))
# Calculate the length of each side of the triangle
side1 = math.sqrt((x2 - x1)**2 + (y2 - y1)**2)
side2 = math.sqrt((x3 - x2)**2 + (y3 - y2)**2)
side3 = math.sqrt((x1 - x3)**2 + (y1 - y3)**2)
# Calculate the perimeter of the triangle
perimeter = side1 + side2 + side3
# Print the perimeter
print(f"The perimeter of the triangle is: {perimeter:.2f} units.")