Python Program Question Unitwise
Python Program Question Unitwise
2. Write a Python program which iterates the integers from 1 to 50. For
multiples of three print "Fizz" instead of the number and for the multiples of
five print "Buzz". For numbers which are multiples of both three and five print
"FizzBuzz".
3. Write a Python program which calculates the frequency of students for the
given range of marks:
i.e. For the marks entered for 20 students out of 100
a. 0-39 = 2
b. 40-59 = 4
c. 60-69 = 10
d. 70-89 = 3
e. 90-100=1
4. Write a Python program to create the multiplication table (from 1 to 10) of
any number.
5. Write a Python script to calculate the BMI of a person.
6. Write a Python script to calculate the summation of first 20 natural
numbers.
7. Calculate electricity bill of your house.
8. Calculate the net salary of an employee from the given details of basic
salary, allowances and income tax slabs.
9. Factorial of a given number.
SHRI VILE PARLE KELAVANI MANDAL’S
SHRI BHAGUBHAI MAFATLAL POLYTECHNIC
Sample Output:
Original lists:
[2, 4, 7, 0, 5, 8]
[3, 3, -1, 7]
3.3 Dictionary
1. Write a Python script to check whether a given key already exists in a
dictionary.
2. Write a Python program to print all unique values in a dictionary.
Sample Data: [{"V":"S001"}, {"V": "S002"}, {"VI": "S001"}, {"VI": "S005"},
{"VII":"S005"}, {"V":"S009"}, {"VIII":"S007"}]
3. Write a Python program to sum all the items in a dictionary.
4. Write a Python program to map two lists into a dictionary.
5. populate a dictionary of 5 elements with key as random number from 1
to 100 and value as square of that number. Write python script to
calculate average of all values
6. Write a Python program to get the top three items in a shop.
Sample data: {'item1': 45.50, 'item2':35, 'item3': 41.30, 'item4':55,
'item5': 24}
Expected Output: item4 55 item1 45.5 item3 41.3
SHRI VILE PARLE KELAVANI MANDAL’S
SHRI BHAGUBHAI MAFATLAL POLYTECHNIC
3.4 Set
1. Display the element in a given set that are not in another set
2. Remove the common element from both the set
3. Write a Python program to find maximum and the minimum value in a
set.
3.5 Tuple
1. n_tuple = ("ComputerIT", [8, 4, 6], (1, 2, 3)) for the above shown tuple
write statements that prints 2 and prints ‘r’
2. Write a Python program to find the repeated items of a tuple.
3. Write a Python program to replace the last value of tuples in a list.
Sample list: [(10, 20, 40), (40, 50, 60), (70, 80, 90)]
Expected Output: [(10, 20, 100), (40, 50, 100), (70, 80, 100)]
5. Write a Python script to display random numbers from the range (1,200)
with the step count as 2.
6. Using in-built python modules write the code snippets for the following:
a. creation and deletion of folder/directory
b. display the date in dd-mm-yyyy format
c. display the calendar of “July 2022” month
d. shuffle the element of given list
7.
8.
9.
10.
11.
10.
3. Write the python script to create connection object and cursor object for
connecting with Mysql database.
5.
6.