Skip to content
62 changes: 62 additions & 0 deletions BMI_Calculator_01.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
"""
We will use this script to learn Python:Concepts of _Class and Objects in BMI Calculator.
The script is an example of BMI_Calculator implemented in Python using methods and constructor.
The BMI_Calculator:
# Get the weight(Kg) of the user
# Get the height(m) of the user
# Caculate the BMI using the formula
BMI=weight in kg/height in meters*height in meters


"""
class BMI_Calculator:
pass

#class variable
BMI = 'calculator'

#The init constructor for weight & height
def __init__(self,weight,height):

#instance variable
self.weight = weight
self.height = height


#another instance constructor for weight & height
def calculate_BMI(self):
return round((self.weight/(self.height*self.height)),2)


weight = float(input("Enter the weight in kg:"))
height = float(input("Enter the height in meters:"))

#object instant
BMI_file = BMI_Calculator(weight, height)
print("The BMI of the user is: ", BMI_file.calculate_BMI(), "kg/sq.metre")
# inputs for the weight & height of the user

BMI_Calculator =BMI_file.calculate_BMI()

if BMI_Calculator< 18.5:
print("Oh No!!! UnderWeight")
print("The Ideal BMI Range is : 18.5 to 25 ")
Gain_Weight = round((18.5 * weight * height - weight), 2)
print("Weight to be Gained to Reach the Ideal BMI is:", Gain_Weight, "Kg")

elif BMI_Calculator >= 18.5 and BMI_Calculator <= 25:
print("Hurrayyy!!! NormalWeight")
print("The Ideal BMI Range is : 18.5 to 25")
print("Good Keep It Up")

elif BMI_Calculator > 25 and BMI_Calculator <= 29.99:
print("Ohhh!!! OverWeight")
print("The Ideal BMI Range is : 18.5 to 25")
Reduce_Weight = round((weight - height * height * 25), 2)
print("Weight to be Reduced to Reach the Ideal BMI is :", Reduce_Weight,"Kg")

elif BMI_Calculator >= 30:
print("{face screaming in fear}")
print("The Ideal BMI Range is : 18.5 to 25")
Reduce_Weight = round((weight - height * height * 25), 2)
print("Weight to be Reduced to Reach the Ideal BMI is :{1}", Reduce_Weight, "Kg")
1 change: 1 addition & 0 deletions BMR/BMR_01.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1. Added configparser library to this program.
16 changes: 16 additions & 0 deletions BMR/Config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[Male]
constant_for_male = 88.362
weight_constant_for_male = 13.397
height_constant_for_male = 4.799
age_constant_for_male = 5.677

[Female]
constant_for_female = 447.593
weight_constant_for_female = 9.247
height_constant_for_female = 3.098
age_constant_for_female = 4.33

[Conversion]
pound = 2.204
foot = 3.28

20 changes: 20 additions & 0 deletions BMR/helper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import configparser

subject_file = configparser.ConfigParser()

subject_file.add_section("Male")
subject_file.set("Male", "Constant_For_Male", "88.362")
subject_file.set("Male", "Weight_Constant_For_Male", "13.397")
subject_file.set("Male", "Height_Constant_For_Male", "4.799")
subject_file.set("Male", "Age_Constant_For_Male", "5.677")

subject_file.add_section("Female")
subject_file.set("Female", "Constant_For_Female", "447.593")
subject_file.set("Female", "Weight_Constant_For_Female", "9.247")
subject_file.set("Female", "Height_Constant_For_Female", "3.098")
subject_file.set("Female", "Age_Constant_For_Female", "4.33")

subject_file["Conversion"]={"Pound":"2.204","foot" : "3.28"}

with open(r"Config.ini", 'w') as configfile:
subject_file.write(configfile)
3 changes: 3 additions & 0 deletions Read Me.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Work in progress:
1. Have to add function keys of lowercase and uppercase.
2. Have to configure a file in which the variables would work like function and import to mainscript.