-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathallfunc.py
More file actions
57 lines (52 loc) · 1.57 KB
/
Copy pathallfunc.py
File metadata and controls
57 lines (52 loc) · 1.57 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
#!/usr/bin/env python3.7
def calc_bmi(weight, height, system="metric", rounded=False):
"""
This funcion calculates BMI (Body Mass Index) using the input
parameters of weight, height and metric system.
calc_bmi(weigh=float/int,height=float/int,system=str(metric/imperial),rounded=bool(optional))
"""
if(system == 'metric' or system == 'imperial'):
bmi = (weight / (height ** 2))
if system == 'metric':
if not rounded:
return round(bmi,1)
else:
return round(bmi)
else:
if system == 'imperial':
if not rounded:
return round((703 * bmi),1)
else:
return round((703 * bmi))
return 'Error: No valid system!'
def parse_list(lista):
"""
parse_list(a) parses a list, creating three lists: strings, numbers and lists
"""
numlist = []
strlist = []
listlist = []
for i in lista:
if isinstance(i, int) or isinstance(i, float):
numlist.append(i)
elif isinstance(i, str):
strlist.append(i)
elif isinstance(i, list):
listlist.append(i)
else:
pass
return strlist, numlist, listlist
def num_count(lista):
"""
num_count will add all numbers in a list
and will count the numbers also.
"""
total = 0
items = 0
for i in lista:
if isinstance(i, int) or isinstance(i, float):
total += i
items += 1
else:
pass
return total, items