# | include: false
import numpy as np
import pandas as pd
256852) np.random.seed(
Functions (Need) Exercises![](exerise_icon.png)
Exercise 1 (Do you know why?) ☻
The following code works as expected despite not having an else
statement. Please use a Markdown cell to explain why?
def greeting(name):
if name == 'Batman':
return 'Hello Batman! So, nice to meet you!'
return f'Hello {name}!'
Exercise 2 (Chubby or not) ☻
Write a Python function named calculate_bmi
.
- The function should take two parameters:
weight
(in kilograms) andheight
(in meters). - The function should calculate the BMI (Body Mass Index) using the formula
BMI = weight / (height ** 2)
. - Based on the calculated BMI, the function should return a string indicating the BMI category based on the following criteria:
Category | BMI Range |
---|---|
Underweight | BMI less than 18.5 |
Normal weight | BMI between 18.5 and 24.9 |
Overweight | BMI between 25 and 29.9 |
Obesity | BMI 30 or more |