We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2
احمد حسين كامل: االسم
AI: القسم
Write a program that calculates the area of a triangle using
three points(x,y):
def triangle_area(x1, y1, x2, y2, x3, y3):
return abs(0.5 * ((x1*(y2-y3)) + (x2*(y3-y1)) + (x3*(y1-y2)))) x1 = float (input("Enter the x coordinates of vertex 1: ")) y1 = float (input("Enter the y coordinates of vertex 1: ")) x2 = float (input("Enter the x coordinates of vertex 2: ")) y2 = float (input("Enter the y coordinates of vertex 2: ")) x3 = float (input("Enter the x coordinates of vertex 3: ")) y3 = float (input("Enter the y coordinates of vertex 3: ")) area = triangle_area(x1, y1, x2, y2, x3, y3) print("The area of the triangle is:", area)
Calculate sum of numbers from 1 to 100000:
sum_of_numbers = 0 for number in range(1, 100001): sum_of_numbers += number print("The sum of numbers from 1 to 100000 is: " ,sum_of_numbers )