Skip to content
Introduction to SQL
  • AI Chat
  • Code
  • Report
  • Spinner
    # Define a function to calculate BMI
    def calculate_bmi(weight, height):
        bmi = weight / (height ** 2)
        return bmi
    
    # Define a list of family members' weights in kg
    weights = [70, 65, 80, 75, 90]
    
    # Define a list of family members' heights in meters
    heights = [1.7, 1.6, 1.8, 1.75, 1.85]
    
    # Calculate the BMI of each family member using a for loop
    for i in range(len(weights)):
        bmi = calculate_bmi(weights[i], heights[i])
        print(f"The BMI of family member {i+1} is {bmi:.2f}")