code to obtain the area of a triangle in python in python

To calculate the area of a triangle in python, you can use the following code:

main.py
import math

base = 10
height = 5

area = 0.5 * base * height

print("The area of the triangle is: ", area)
108 chars
9 lines

In this example, we define the base and height of the triangle as variables. We then use the formula for calculating the area of a triangle (area = 1/2 * base * height) to calculate the area. Finally, we print the result using the print() function. You can replace the values of base and height with the actual values of the triangle you are trying to calculate the area for.

gistlibby LogSnag