Created
June 18, 2022 08:35
-
-
Save paley777/4cdae9da65c9ede620f79109077c22c8 to your computer and use it in GitHub Desktop.
calculate the area of a flat shape using python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Mencetak Menu | |
def menu(): | |
print("1. Persegi Panjang") | |
print("2. Lingkaran") | |
print("3. Segitiga") | |
print("4. Keluar") | |
def persegi(): | |
print("Menghitung Luas Persegi Panjang") | |
pil1 = int(input("\nMasukkan Panjang : ")) | |
pil2 = int(input("\nMasukkan Lebar : ")) | |
Luas = pil1 * pil2 | |
print("Luas Persegi Panjang adalah ", Luas) | |
print("Coba lagi[Y / N]? ") | |
back = str(input("\nMasukkan Jawaban : ")) | |
if back == "Y": | |
menu() | |
else: | |
exit() | |
def lingkaran(): | |
print ("Menghitung Luas Lingkaran") | |
r = int(input("Masukkan Jari - Jari: ")) | |
luas = 3.14 * (r ** 2) | |
print ("Luas Lingkaran adalah ", luas) | |
print ("Coba lagi[Y / N]? ") | |
back = str(input("\nMasukkan Jawaban : ")) | |
if back == "Y": | |
menu() | |
else: | |
exit() | |
def segitiga(): | |
print ("Menghitung Luas Segitiga") | |
a = int(input("Masukkan Alas: ")) | |
t = int(input("Masukkan Tinggi: ")) | |
luas = (a * t) / 2 | |
print ("Luas Segitiga adalah ", luas) | |
print ("Coba lagi[Y / N]? ") | |
back = str(input("\nMasukkan Jawaban : ")) | |
if back == "Y": | |
menu() | |
else: | |
exit() | |
# Program Menghitung Luas | |
print ("Selamat") | |
print ("———————————————–") | |
menu() | |
while l: | |
# input | |
pilih = input("Masukkan pilihan: ") | |
if pilih == 1: | |
persegi() | |
elif pilih == 2: | |
lingkaran() | |
elif pilih == 3: | |
segitiga() | |
elif pilih == 4: | |
print ("\n") * 100 | |
else: | |
print ("Maaf pilihan yang anda masukkan tidak terdaftar") | |
print ("Coba lagi[Y / N] ? ") | |
coba = raw_input().upper() | |
if coba == "Y": | |
menu() | |
else: | |
print ("\n") * 100 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment