Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#define and initialize 4 dicts to represent patients patient_0 = {'name': 'bob', height: 66, weight: 150} patient_1 = {'name': 'betty', height: 62, weight: 100} patient_2

#define and initialize 4 dicts to represent patients patient_0 = {'name': 'bob', "height": 66, "weight": 150} patient_1 = {'name': 'betty', "height": 62, "weight": 100} patient_2 = {'name': 'liz' , "height": 50, "weight": 140} patient_3 = {'name': 'chris', "height": 70, "weight": 110}

#store the dicts in a list patients = [patient_0, patient_1, patient_2, patient_3]

#print program name and report header line print("BMI Program: ") print(f"{'NAME':<15}{'BMI':<10}{'CLASSIFICATION'} ")

#Calc bmi by accessing list of dicts for patient in patients: bmi = (patient['weight'] * 703) / (patient['height'] * patient['height']) #classification if bmi >= 25: classification = "Overweight" elif bmi >= 18.5: classification = "Healthy" elif bmi >= 16: classification = "Underweight" else: classification = "Invalid" #patient name and classification print(f"{patient_0['name'].title():<15}{bmi:<10.2f}{classification} ") print(f"{patient_1['name'].title():<15}{bmi:<10.2f}{classification} ") print(f"{patient_2['name'].title():<15}{bmi:<10.2f}{classification} ") print(f"{patient_3['name'].title():<15}{bmi:<10.2f}{classification} ")

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Object Databases The Essentials

Authors: Mary E. S. Loomis

1st Edition

020156341X, 978-0201563412

More Books

Students also viewed these Databases questions