Data Science
Lab Exercise (Week 1 )
Python Basics Practice
Go through the Python tutorial
[Link]
1. The Body Mass Index (BMI) of a person is calculated as:
Write a Python program that: Takes weight (kg) and height (m) as input from the user.
Calculates the BMI and prints [Link] the BMI into the following categories:
BMI < 18.5 → print "Underweight"
18.5 ≤ BMI < 24.9 → print "Normal weight"
25 ≤ BMI < 29.9 → print "Overweight"
BMI ≥ 30 → print "Obese"
Hint: Use float(input()) to take weight and height. Round BMI to 2 decimal places for
printing.
2. Write a Python program that takes a list of integers from the user and counts how
many numbers are even and how many are odd.
3. Write a Python function named greater() that counts how many elements in a list
are greater than a given number n.
x = [5, 12, 18, 7, 25, 3], n=10
greater(x, 10) → 3
4. Given a list of numbers, write a Python program to create a new list after
removing all negative values, keeping the original order.
5. Write a Python program that takes a number from the user and prints its square
and cube.
6. Create a variable growth_rate = 1.15.
Take current population as input and calculate the population after 5 years
assuming compound growth.
7. Write a Python program that converts kilograms to pounds using the formula:
Take input from the user and display the result.
8. Create a list that stores room names and their areas as strings, such as:
["hall 10.5", "kitchen 7.2", "bedroom 13.8", "bathroom 4.5"]
Print each room and its area on a separate line.
9. With two given lists [1,3,6,78,35,55] and [12,24,35,24,88,120,155], write a
program to make a list whose elements are intersection of the above given lists.
Hints: Use set() and "&=" to do set intersection operation.]
10. Create a list Score that contains the GPA of a student in 6 semesters. Create 3
such students and add them in new list call Students with the name of the student with
it as well.