Triangle area
Write a program that receives the rule and height of the triangle and calculates its area
Triangle area = (rule * height) divided by 2
Write a program that receives the rule and height of the triangle and calculates its area
Triangle area = (rule * height) divided by 2
let msg = 'error' | |
alert(msg) |
This answer is only visible to premium members
let msg = 'error' | |
alert(msg) |
This answer is only visible to premium members
let msg = 'error' | |
alert(msg) |
This answer is only visible to premium members
X=float(input("x: ")) | |
H=float(input("y: ")) | |
print("s:",X*H/2)X=float(input("x: ")) |
There is an extra part of the end of the code that should be erased
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() |
x = float(input("inter x :")) | |
y = float(input("inter y :")) | |
a = (x * y) /2 | |
print(a) |
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) |
height=float(input("Enter heigt: ")) | |
base=float(input("Enter base: ")) | |
area=height*base*0.5 | |
print("area=",area) |
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() |
Submitting answers is currently unavailable.
برای استفاده از این بخش باید وارد حساب کاربریت بشی
ورود/ثبت نام If you don’t understand the exercise or can’t solve it for any reason, that’s completely
normal—don’t worry 😊
Try checking out easier exercises and reviewing different answers
submitted by others. Gradually, you can move on to more challenging exercises. Also, your answer
might be correct even if it’s different from others.