0% found this document useful (0 votes)
11 views4 pages

Lab-02 Functions Classwork

Uploaded by

arafjaman2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views4 pages

Lab-02 Functions Classwork

Uploaded by

arafjaman2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Course Code: CSE111

Course Title: Programming Language II

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

Hint: Total Price = meal_cost + delivery_charge + tax


Note that:
● If your home is in the Mohakhali area then your delivery charge is 40
taka else 60 taka
● Your tax rate is 8% of your meal.
Task 3

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

* The old domain (Use Default argument technique to handle this)

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.

You might also like