Upload files to "basic programming/1st task"
This commit is contained in:
24
basic programming/1st task/10.py
Normal file
24
basic programming/1st task/10.py
Normal 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.")
|
||||
Reference in New Issue
Block a user