Skip to content
This repository was archived by the owner on Apr 24, 2025. It is now read-only.

Commit e50bf48

Browse files
Merge pull request #717 from Monish-Kumar-D/main
BMI Calculator - special feature of tabulating reference chart
2 parents cb82d8a + 558b779 commit e50bf48

3 files changed

Lines changed: 28 additions & 0 deletions

File tree

projects/BMI_calculator/BMI calculator.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
import tabulate
2+
import csv
3+
4+
def reference_chart():
5+
"""
6+
This is a function used to tabulate the data
7+
of the bmi scale for the user, this requries a csv file 'bmi.csv' and two libraries "csv" and "tabulate".
8+
It won't take any arguments and won't return anything
9+
"""
10+
list2=[]
11+
with open('bmi.csv') as file1:
12+
list1=csv.reader(file1)
13+
for line in list1:
14+
list2.append(line)
15+
print("Here You can take the reference chart \n")
16+
print(tabulate.tabulate(list2[1:],headers=list2[0],tablefmt='fancy_grid'))
17+
18+
119
def calculate_bmi(height, weight):
220
"""
321
Calculate BMI given height (in meters) and weight (in kilograms).
@@ -44,6 +62,7 @@ def interpret_bmi(bmi):
4462

4563

4664
def main():
65+
reference_chart()
4766
try:
4867
height = float(input("Enter your height in meters: "))
4968
weight = float(input("Enter your weight in kilograms: "))

projects/BMI_calculator/bmi.csv

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
ranges,condition
2+
<18.5,underweight
3+
18.5 - 24.9,normal
4+
24.9 - 29.9,overweight
5+
29.9 - 34.9,obese (Class I)
6+
34.9 - 39.9,obese (Class II)
7+
39.9<,obese (Class III)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1.tabulate
2+
2.csv

0 commit comments

Comments
 (0)