Created
August 22, 2020 04:49
-
-
Save PhilipPurwoko/3d47f4e4ab0cb39669c29cb464da05ff to your computer and use it in GitHub Desktop.
Kalkulator BMI sederhana dengan 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
# Mendapatkan informasi dari input pengguna | |
berat_badan = int(input('Berat Badan (kg) : ')) | |
tinggi_badan = int(input('Tinggi Badana (cm) : ')) | |
# Konversi tinggi badan ke meter | |
tinggi_badan = tinggi_badan/100 | |
# Rumus BMI = berat badan(kg) / (tinggi badan(m) ^ 2) | |
nilai_bmi = berat_badan / (tinggi_badan**2) | |
print('Nilai BMI anda : ',nilai_bmi) | |
# Sistem logika dengan if else | |
if nilai_bmi < 18.5: | |
print('Berat badan anda kurang ') | |
elif nilai_bmi > 18.5 and nilai_bmi < 24.9: | |
print('Berat badan anda normal') | |
elif nilai_bmi > 25 and nilai_bmi < 29.9: | |
print('Anda kelebihan berat badan') | |
elif nilai_bmi > 30: | |
print('Anda obesitas') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment