Functions (Need) Exercises
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?
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 |
| Obese | BMI 30 or more |
Exercise 3 (Factorials) Write a function that accepts an integer n and returns its factorial. Ensure that your function gracefully handles negative numbers.