Python Program to Calculate Area of Triangle

Area of triangle in python. In Python, print the area of triangle program. This python program will run the program using the triangle’s area and length, and it will print the triangle’s area.

print("Enter the Length")
b = float(input())
print("Enter the Height Length")
h = float(input())
a = 0.5 * b * h
print("\nArea = ", a)

 

Output:

Enter the Length 45

Enter the Height Length 45

Area =  1012.5

Print Statement in Python

The print() method outputs the message supplied to the screen or another standard output device. The message can be a string or any other object; the object will be converted to a string before being displayed on the screen. The print statement instructs the computer to output anything, either to the terminal or to the printer. It may be utilised in a variety of ways. Printing the value of a single variable is one method.

Triangle Definition for Python

A triangle is a form that exists in two dimensions. It has three vertices and three straight sides. A triangle’s three angles always sum up to 180°. (180 degrees). It is the polygon with the fewest number of sides.

Float Definition in Python

In Python, the float() method converts a number stored in a string or integer to a floating point number or a decimal point number. In Python, there are two sorts of numbers: floating-point numbers (floats) and integers. Integers cannot include decimals, although floats may.

In Python, the float type represents a floating point number. Float is a type of number that is used to represent real numbers and is written with a decimal point to separate the integer and fractional components. Float is an abbreviation meaning “floating point.” It’s a basic data type included into the compiler that’s used to define numeric values with floating decimal points.