
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
How to Calculate the Area of a Triangle using Python?
Calculating the area of a triangle is a formula that you can easily implement in python. If you have the base and height of the triangle, you can use the following code to get the area of the triangle,
def get_area(base, height): return 0.5 * base * height print(get_area(10, 15))
This will give the output:
75
If you have the sides of the triangle, you can use herons formula to get the area. For example,
def get_area(a, b, c): s = (a+b+c)/2 return (s*(s-a)*(s-b)*(s-c)) ** 0.5 print(get_area(10, 15, 10))
This will give the output:
49.607837082461074
- Related Articles
- Java Program to calculate the area of a triangle using Heron's Formula
- Python Program to calculate the area of a Tetrahedron
- Program to calculate area and perimeter of equilateral triangle
- Program to calculate area of Circumcircle of an Equilateral Triangle
- Python Program to calculate the area of Cube
- Swift Program to Calculate Area and Perimeter of Equilateral Triangle
- Python Program to calculate the area of the rhombus
- C++ Program to Compute the Area of a Triangle Using Determinants
- Program to calculate area and perimeter of equilateral triangle in C++
- Program to calculate area of Circumcircle of an Equilateral Triangle in C++
- How to find the area of the triangle?
- Python Program to calculate the volume and area of Cone
- Python Program to calculate the volume and area of Sphere
- Program to calculate the Area and Perimeter of Incircle of an Equilateral Triangle\nWhat is Equilateral Triangle in C?
- Python Program to calculate the volume and area of the Cylinder

Advertisements