Home / Programs / Write a Python program that accepts the base and height of the triangle as inputs and compute the area.
🚀 Programming Example

Write a Python program that accepts the base and height of the triangle as inputs and compute the area.

👁 227 Views
💻 Practical Program
📘 Step Learning
A triangle is any polygon that has 3 edges and three vertices. The code below illustrates how you can compute the area of the triangle:

💻 Program Code

base = int(input("Input the value  of the base :")) #Enter the base of the triangle
height = int(input("Input the value of the height :")) #Enter the height of the triangle
area = base*height/2 # Formula for computing the area
print("The  area  of  the  triangle  is =", area) #Display the area of the triangle
                        

🖥 Program Output

Input the value  of the base :12
Input the value of the height :15
The  area  of  the  triangle  is = 90.0
                            

📘 Explanation

no
📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.