-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.py
More file actions
89 lines (68 loc) · 1.94 KB
/
Copy pathclient.py
File metadata and controls
89 lines (68 loc) · 1.94 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
'''
float get_height(feet, inches)
(bool, float) valid_weight(weight)
bool valid_bmi_values(height, weight)
(float, string) get_bmi(height, weight)
'''
def get_height(feet, inches):
return (int(feet)*12) + float(inches)
def valid_weight(weight):
valid = False;
try:
weight = float(weight)
# x > 0
if (weight > 0):
valid = True;
except Exception: # Non float values
valid = False;
return (valid, weight)
def valid_bmi_values(height, weight):
return type(height) == float and type(weight) == float
def get_bmi(height, weight):
bmi = (weight * 0.45) / ((height * 0.025)**2)
bmi = round(bmi,1)
category = ''
if (bmi < 18.5):
category = 'Underweight'
elif (bmi >= 18.5 and bmi <= 24.9):
category = 'Normal weight'
elif (bmi >= 25 and bmi <= 29.9):
category = 'Overweight'
else:
category = 'Obese'
return (bmi, category)
'''
(bool, float) valid_salary(salary)
(bool, float) valid_save_goal(save_goal)
bool valid_retirement_values(age, salary, percent_saved, save_goal)
(bool, int) get_retirement_age(age, salary, percent_saved, save_goal)
'''
def valid_salary(salary):
valid = False;
try:
salary = float(salary)
# x > 0
if (salary > 0):
valid = True;
except Exception: # Non float values
valid = False;
return (valid, salary)
def valid_save_goal(save_goal):
valid = False;
try:
save_goal = float(save_goal)
# x > 0
if (save_goal > 0):
valid = True;
except Exception: # Non float values
valid = False;
return (valid, save_goal)
def valid_retirement_values(age, salary, percent_saved, save_goal):
return type(age) == int and type(salary) == float and type(percent_saved) == float and type(save_goal) == float
def get_retirement_age(age, salary, percent_saved, save_goal):
percent_saved *= 1.35
years = save_goal / (salary * (percent_saved/100))
age_met = years + age
age_met = round(age_met)
met = age_met < 100
return (met, age_met)