# Python Exercise – Accept the base and height of a triangle and compute the area

## (Python Example for Citizen Data Scientist & Business Analyst)

Write a Python program that will accept the base and height of a triangle and compute the area.

Python: Area of a triangle

A triangle is a polygon with three edges and three vertices. It is one of the basic shapes in geometry. A triangle with vertices A, B, and C is denoted triangle ABC.

• Vertex of a triangle: The point at which two sides of a triangle meet.
• Altitude of a triangle: The perpendicular segment from a vertex of a triangle to the line containing the opposite side.
• Base of a triangle: The side of a triangle to which an altitude is drawn.
• Height of a triangle: The length of an altitude.

Sample Solution

Python Code:

``````b = int(input("Input the base : "))
h = int(input("Input the height : "))

area = b*h/2

print("area = ", area)
``````

Sample Output:

```Input the base : 20
Input the height : 40
area =  400.0```

## Applied Machine Learning & Data Science with Python, R and SQL.

A list of Python, R and MATLAB Codes for Applied Machine Learning and Data Science https://setscholars.net/

Learn by Coding Categories:

Classification: https://setscholars.net/category/classification/

Data Analytics: https://setscholars.net/category/data-analytics/

Data Science: https://setscholars.net/category/data-science/

Data Visualisation: https://setscholars.net/category/data-visualisation/

Machine Learning Recipe: https://setscholars.net/category/machine-learning-recipe/

Supervised Learning: https://setscholars.net/category/supervised-learning/

Tabular Data Analytics: https://setscholars.net/category/tabular-data-analytics/

End-to-End Data Science Recipes: https://setscholars.net/category/a-star-data-science-recipe/

Applied Statistics: https://setscholars.net/category/applied-statistics/

Bagging Ensemble: https://setscholars.net/category/bagging-ensemble/

Boosting Ensemble: https://setscholars.net/category/boosting-ensemble/

Clustering: https://setscholars.net/category/clustering/

Data Analytics: https://setscholars.net/category/data-analytics/

Data Science: https://setscholars.net/category/data-science/

Data Visualisation: https://setscholars.net/category/data-visualisation/

Decision Tree: https://setscholars.net/category/decision-tree/

Machine Learning Recipe: https://setscholars.net/category/machine-learning-recipe/

Multi-Class Classification: https://setscholars.net/category/multi-class-classification/

Neural Networks: https://setscholars.net/category/neural-networks/

Python Machine Learning: https://setscholars.net/category/python-machine-learning/

Python Machine Learning Crash Course: https://setscholars.net/category/python-machine-learning-crash-course/

R Classification: https://setscholars.net/category/r-classification/

R for Beginners: https://setscholars.net/category/r-for-beginners/

R for Data Science: https://setscholars.net/category/r-for-data-science/

R for Data Visualisation: https://setscholars.net/category/r-for-data-visualisation/

R for Excel Users: https://setscholars.net/category/r-for-excel-users/

R Machine Learning: https://setscholars.net/category/r-machine-learning/

R Machine Learning Crash Course: https://setscholars.net/category/r-machine-learning-crash-course/

R Regression: https://setscholars.net/category/r-regression/

Regression: https://setscholars.net/category/regression/

Excel examples for beginners: https://setscholars.net/category/excel-examples-for-beginners/

C Programming tutorials & examples: https://setscholars.net/category/c-programming-tutorials/

Javascript tutorials & examples: https://setscholars.net/category/javascript-tutorials-and-examples/

Python tutorials & examples: https://setscholars.net/category/python-tutorials/

R tutorials & examples: https://setscholars.net/category/r-for-beginners/

```