0% found this document useful (0 votes)
94 views8 pages

Python Program Question Unitwise

The document provides a list of programming problems and exercises related to various Python concepts like control flow, strings, lists, tuples, dictionaries, sets, functions, OOP, exceptions, regular expressions, file handling and GUI programming. It also includes exercises on database connectivity. Students are expected to write Python code to solve the problems.

Uploaded by

radha
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
94 views8 pages

Python Program Question Unitwise

The document provides a list of programming problems and exercises related to various Python concepts like control flow, strings, lists, tuples, dictionaries, sets, functions, OOP, exceptions, regular expressions, file handling and GUI programming. It also includes exercises on database connectivity. Students are expected to write Python code to solve the problems.

Uploaded by

radha
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 8

SHRI VILE PARLE KELAVANI MANDAL’S

SHRI BHAGUBHAI MAFATLAL POLYTECHNIC

Programme: Computer Engineering Semester: IV


Course: Programming in Python Course code: PRP228918
Python Practical & Theory Programs Question Bank

Unit 2: Control flow


1. Write a Python program to check a triangle is equilateral, isosceles or
scalene.
Expected Output:
Input lengths of the triangle sides:
x: 6
y: 8
z: 12
Scalene triangle

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

10. Triangle Pattern Programs of C/C++


11. Use the for loop and elif in a python script that counts and displays all
letters, digits and special symbols in a string “Python 33345 $_Programming”
12. Use the while loop and write a python program that prints the odd
numbers in a list
13. Write the Python Script that replaces the white spaces with ‘#’ in the
given below given string. str = "Python Programming in academics"
14.

Unit 3: String, List, Tuple, Dictionary and Set


3.1 String
1. Count number of words from a given string.
2. Check whether given email address contains both ‘@’ and ‘.’ symbol
or not.
3. Display different words of a given string.
4. display words having minimum 5 characters and end with ’t’ from the
given list of strings
5. Extract the file name from the given file path and display it on the
screen. Also display the message with which application this file
should be opened.
i.e. The input string is “d:/subjects/Java/Exercises/Exercise1.doc”
6. Analyse the below given python statements and state the output of
each statement
if str=”ComputerEngineering”
print(str[:6])
print(str[5:4])
print(str[-1:-12:-1])
print(str[::-1])
3.2 List
1. Write a Python program to sum all the items in a list.
2. Write a Python program to multiplies all the items in a list.
3. Write a Python program to get the largest/smallest number from a list.
SHRI VILE PARLE KELAVANI MANDAL’S
SHRI BHAGUBHAI MAFATLAL POLYTECHNIC

4. Write a Python Script to display numbers multiple of 3 and 5 from the


given list.
5. Remove empty strings from the list of strings
a. list1 = ["Mike", "", "Emma", "Kelly", "", "Brad"]
6. Write a python script to check duplicate element in the list.
7. Display words starts with ‘k’ from the given list of strings.
8. Write a python script to display list with single of occurrence element
(No duplication)
9. Write the List Comprehension statements that gives the following
output. [18, 16,14,12,10,8,6,4,2]
10. Write a Python program to add two given lists of different lengths,
starting on the right.

Sample Output:
Original lists:
[2, 4, 7, 0, 5, 8]
[3, 3, -1, 7]

Add said two lists from left:


[2, 4, 10, 3, 4, 15]

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

7. Write a Python program to combine two dictionary adding values for


common keys. Go to the editor
d1 = {'a': 100, 'b': 200, 'c':300}
d2 = {'a': 300, 'b': 200, 'd':400}
Sample output: Counter ({'a': 400, 'b': 400, 'd': 400, 'c': 300})
8. Write a Python script to generate and print a dictionary that contains a
number (between 1 and n) in the form (x, x*x).
Sample Dictionary ( n = 5) :
Expected Output : {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}

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)]

Unit 4: Functions, Modules and Packages


1. Write a Python program to generate a random integer between 0 and 6
- excluding 6, random integer between 5 and 10 - excluding 10, random
integer between 0 and 10, with a step of 3 and random date between
two dates.
2. Write a Python program to shuffle the elements of a given list.
3. Write a Python program to create a list of random integers and
randomly select multiple items from the said list.
4. Write a Python program to select a random element from a list, set,
dictionary-value, and file from a directory.
SHRI VILE PARLE KELAVANI MANDAL’S
SHRI BHAGUBHAI MAFATLAL POLYTECHNIC

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

Unit 5: OOP, Exception Handling and Multithreading

1. Implement the inheritance shown in the above figs.


2. Write a Python script to read data of n students (roll number, name,
address and marks of 5 subject) display the data and also percentage of
each student. Use array of object to read and display n students’ information.
3. Write a Python Script to define a class BookStore with constructor that
initializes essential attributes. Also calculate total valuation and develop
member methods to update price and quantity of a book. Use array of
objects to read data of n books.
4. Write a python script to overload == operator
5. Write a multithreaded python script to count leap years from year 1700 to
2000. Divide the task among 3 threads equally and also display the total leap
years
6. Write a Python script to define a class for matrix, perform the addition of 2
matrices and display it.
SHRI VILE PARLE KELAVANI MANDAL’S
SHRI BHAGUBHAI MAFATLAL POLYTECHNIC

7.

8.

9.

10.

11.

12. Write a multithreaded program to count word of a string. Create 3


threads, assign each one a different string and display individual thread
count as well as total count
13. Write a python script to overload bitwise not operator.
SHRI VILE PARLE KELAVANI MANDAL’S
SHRI BHAGUBHAI MAFATLAL POLYTECHNIC

Unit 6: Regular Expression and File processing


1. Write a regular expression in python to display the date yyyymmdd
separated by underscore (_) or slash (/) of the month April (04) and May
(05).
2. Write a python script to check the valid email id out of the given email
addreses
3. Write a regular expression in python script to display the name with the
tag Mr.
4. Write a python program to extract all mobile numbers present in input.txt
where numbers are mixed with normal text data
5. Write the Python Script that replaces the white spaces with ‘$’ in the given
below given string.
str = "I like programming in Python.
6. Write a Python script to copy content of one file(text/binary) to another file.
7. Write a Regular Expression to represent all 10 digit mobile numbers
Rules:
1. Every number should contain exactly 10 digits
2. The first digit should be 7 or 8 or 9

8. Write a Python Program to validate an URL


9.

10.

Unit 7: GUI Programming with database connectivity


1. Write a Python Program to design the above shown form that takes input
from user and stores it in database.
SHRI VILE PARLE KELAVANI MANDAL’S
SHRI BHAGUBHAI MAFATLAL POLYTECHNIC

2. Write a Python Program to design Login form and display if it is


authenticated user or not.

3. Write the python script to create connection object and cursor object for
connecting with Mysql database.

4. Write a Python script to design student/employee registration form and


store the data in database.

5.

6.

7. Develop a Tkinter Frame to design a faculty registration form to participate


in a workshop on ”machine learning.” Add name, email, experience(years)
and department text fields in the form with appropriate labels also add a
“Register” button. As user presses the register button, the faculty record
should be inserted in the data table “registered.” (Use grid manager)

You might also like