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

Commit d4336e1

Browse files
A function added to tabulate the data from the bmi chart
1 parent a481f0d commit d4336e1

1 file changed

Lines changed: 19 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: "))

0 commit comments

Comments
 (0)