-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDiabetes-ReadyReckoner.txt
More file actions
43 lines (35 loc) · 1.45 KB
/
Diabetes-ReadyReckoner.txt
File metadata and controls
43 lines (35 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Ready reckoner for exposure to diabetes.
# Diabetes risk correlates closely with BMI, Blood Sugar (HbA1c), and Age.
# Function to calculate BMI
def calculate_bmi(weight, height):
return weight / (height ** 2)
# Function to calculate diabetes risk factor
def calculate_risk_factor(age, bmi, hba1c):
return (age / 42) * (bmi / 25) * (hba1c / 48)
# Function to determine risk level based on risk factor
def determine_risk_level(factor):
if 0 <= factor < 1:
return "You are below average risk"
elif 1 <= factor < 1.5:
return "You are average risk"
elif 1.5 <= factor < 2:
return "You are above average risk"
else:
return "You are high risk"
# Main function to gather inputs and display results
def main():
# Gathering user inputs
age = int(input("Please enter your Age: "))
height = float(input("Please enter your Height (in meters): "))
weight = float(input("Please enter your Weight (in kilograms): "))
hba1c = int(input("Please enter your HbA1c (blood sugar level): "))
# Calculating BMI
bmi = calculate_bmi(weight, height)
# Calculating Diabetes Risk Factor
factor = calculate_risk_factor(age, bmi, hba1c)
# Displaying results
print(f"Your risk factor for Diabetes with a norm of 1.0 is {factor:.2f}x normal.")
print(determine_risk_level(factor))
# Running the main function
if __name__ == "__main__":
main()