Kalkulator Geometri
Hitung luas, keliling, dan volume lingkaran, persegi panjang, segitiga, dan lainnya.
Pertanyaan yang Sering Diajukan
Implementasi Kode
import math
def circle_area(r: float) -> float:
return math.pi * r ** 2
def circle_circumference(r: float) -> float:
return 2 * math.pi * r
def rectangle_area(l: float, w: float) -> float:
return l * w
def rectangle_perimeter(l: float, w: float) -> float:
return 2 * (l + w)
def triangle_area(base: float, height: float) -> float:
return 0.5 * base * height
def triangle_area_heron(a: float, b: float, c: float) -> float:
s = (a + b + c) / 2
return math.sqrt(s * (s - a) * (s - b) * (s - c))
def sphere_volume(r: float) -> float:
return (4 / 3) * math.pi * r ** 3
def sphere_surface(r: float) -> float:
return 4 * math.pi * r ** 2
def cylinder_volume(r: float, h: float) -> float:
return math.pi * r ** 2 * h
# Examples
print(f"Circle area r=5: {circle_area(5):.4f}") # 78.5398
print(f"Sphere volume r=3: {sphere_volume(3):.4f}") # 113.0973
print(f"Triangle (Heron) 3,4,5: {triangle_area_heron(3,4,5):.4f}") # 6.0000Comments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.