CodeSolved

A comprehensive source of programming questions and exercises

Triangle area

Practice Easy 1230/ Download 409 Views

Write a program that receives the rule and height of the triangle and calculates its area

Triangle area = (rule * height) divided by 2

12 Answers

This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
X=float(input("x: "))
H=float(input("y: "))
print("s:",X*H/2)X=float(input("x: "))
Farbod.313 Download Python

There is an extra part of the end of the code that should be erased Amirhn


def calculate_triangle_area(base, height):
    return (base * height) / 2

def main():
    try:
        base = float(input("لطفاً قاعده مثلث را وارد کنید: "))
        height = float(input("لطفاً ارتفاع مثلث را وارد کنید: "))
        area = calculate_triangle_area(base, height)
        print(f"مساحت مثلث برابر است با: {area}")
    except ValueError:
        print("لطفاً یک عدد معتبر وارد کنید.")

if __name__ == "__main__":
    main()
User 136 Download Python
x = float(input("inter x :"))
y = float(input("inter y :"))
a = (x * y) /2
print(a)
Ali.r.h.z Download Python
def mosallas(ghaedeh,ertefah):
    masahat = (ghaedeh * ertefah) / 2
    return masahat
print(mosallas(ghaedeh=int(input("enter your numnber:")),ertefah=int(input("enter your number:"))))
x=int(input('qaedemorede nazar ra vared konid? \t'))
y=int(input('ertefa ra vared konid? \t'))
print((x*y)//2)
Migmig.i1 Download Python
height=float(input("Enter heigt: "))
base=float(input("Enter base: "))
area=height*base*0.5
print("area=",area)
Faranak Download Python
def calculate_triangle_area(base, height):
    """محاسبه مساحت مثلث."""
    return (base * height) / 2

def main():
    """تابع اصلی برنامه."""
    try:
        # Get input from the user
        base = float(input("لطفاً قاعده مثلث را وارد کنید: "))
        height = float(input("لطفاً ارتفاع مثلث را وارد کنید: "))

        # Calculate the area of ​​the triangle
        area = calculate_triangle_area(base, height)

        # Display the result
        print(f"مساحت مثلث با قاعده {base} و ارتفاع {height} برابر است با: {area}")
    
    except ValueError:
        print("لطفاً یک عدد معتبر وارد کنید.")

if __name__ == "__main__":
    main()
Mma123 Download Python
<< Previous page 1 2 Next page >>

Submit answer

Submitting answers is currently unavailable.

×
×
Close