[2 points] Program Logic
The following Python function prints out the heart disease risk for a person based on age and body mass index (BMI).def heart_risk(age, bmi): if age < 45: if bmi < 22: risk = "low" else: risk = "medium" else: if bmi < 22: risk = "medium" else: risk = "high" print(risk)
def heart_risk(age, bmi): if age < 45: if bmi < 22: risk = "low" else: risk = "medium" else: if bmi < 22: risk = "medium" else: risk = "high" print(risk)What would the function print for a 45 year old person with a bmi of 21 in this case?
[2 pts] Revisit the function sum(n) from Intro to Programming - 2 Lecture Notes.
def findmin(lst): min_num = lst[0] i = 1 while i < len(lst): if lst[i] < min_num: min_num = lst[i] i = i + 1 return min_num
===================================== list min_num i ===================================== [7,4,6,-1,4,19] 7 1 [7,4,6,-1,4,19] 4 2 =====================================
def table1(n): for i in range(1, n + 1): row = [] for j in range(1, n + 1): row.append(i*j) print(row) return None
def table2(m, n): for i in range(1, m + 1): row = [] for j in range(1, n + 1): row.append(i*j) print(row) return None
Hint: If you understand how sieve(n) works and what it returns, it should be easy to answer the questions above. The answers require only minor modifications to the existing function.
def sift_wrong(lst,k): # eliminates multiples of k for i in range(0,len(lst)): if lst[i] % k == 0: lst.remove(lst[i]) return lst