Lab-02 Functions Classwork
Lab-02 Functions Classwork
Classwork No: 02
Topic: Functions
Number of tasks: 6
Task: 1
You are one of the gym instructors at AmiKenoMota. You decide to provide a
customized diet and exercise plan based on the BMI of an individual. You measure
the weight in kilograms and the height in meters and calculate the BMI before a
plan can be decided. Write a BMI function that takes in two values, weight in kg
and height in cm, and print the score along with the condition. (Make sure to
convert cm into m before calculation)
BMI(height, weight)
𝐵𝑀𝐼 = 𝑘𝑔/𝑚2
Based on the BMI score, return the following output.
● < 18.5- Underweight
● 18.5 - 24.9 - Normal
● 25 -30 - Overweight
● > 30 – Obese
Task: 2
You want to order a burger from Chillox through the FoodPanda app. You have to
calculate the total price. Write a function that will take the name of the burger and
place(Mohakhali/Outside of Mohakhali) as input. Use the default argument
technique for taking place input.
Menu Price(Tk)
BBQ Chicken Cheese Burger 250
Beef Burger 170
Naga Drums 200
A company named Sheba.xyz has recently moved from its old domain to a new one.
However, a lot of the company's email addresses are still using the old one. Write a
function in Python that replaces this old domain with the new one for any outdated
email addresses. Keep it the same if the email address contains the new domain. (Do
not use builtin replace function)
Firstly, define a “replace_domain” function that accepts three parameters
*The email address to be checked
*The new domain
Task 4
Write a program that checks whether a given string is a palindrome or not. Note: A
palindrome is a word, phrase, or sequence that reads the same way backward as
forward. For palindromes, any spaces in the middle are not considered and should
be trimmed.
Task 5
Write a function that takes the number of days as input and prints the total
number of years, number of months, and number of days as output.
Task 6
You are a class teacher at a kindergarten school. As a task, you asked your students to
write a paragraph. Unfortunately, you will notice that most of the students did not use
capital letters correctly. Your task is to write a function that takes a string as its only
parameter and returns a new copy of the string that has been correctly capitalized. Your
function should:
● Capitalize the first letter in the string
● Capitalize the first letter after a full-stop, exclamation mark, or question mark
● Capitalize the word “i” if it is in lowercase.
Summary: You have to write a function that reads a string from the user and
capitalizes it. The string is then returned and displayed.