MCA Python Journal

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Sinhgad Technical Education Society’s

Sinhgad Institute of Management

S. No. 44/1, Off Sinhgad Road, Vadgaon (Bk), Pune – 411 041

Practical Journal On

Python Programming
A.Y. 2021-22

Class: MCA – I Semester- II


Index
Sr.no Program
1. Write a python code to find given number is Armstrong Number or Not.
Steps:
a. Accept Number from user in variable named as X.
b. Print message whether number X is Armstrong or not.
Note: Armstrong number is a number that is equal to the sum of cubes
of its digits.
For example 153. (1^3 + 5^3 + 3^3 = 153)
2 Write a code in python to count number of vowels in given string
Steps:
a. Accept string from user in variable named STR1.
b. Count the number of vowels in STR1 and print.
Eg. 1.STR1 = 'COCONUT' => 3
2.STR1 = 'CONFIDence' => 4
3 Write a program, which will find all such numbers between 2000 and
3000 (both included) such that each digit of the number is an even
number.
eg. 2000, 2002...2888.
4 Write a program that accepts a sentence and calculate the number of
letters and digits.
Suppose the following input is supplied to the program: hello world!
123
Then, the output should be: ALPHABETS 10 DIGITS 3
(Note : Special symbols are not alphabets)
5 Write a Python function that takes a list and returns a new list with
unique elements of the first list.
Sample List : [1,2,3,3,3,3,4,5] Unique List : [1, 2, 3, 4, 5]
6 Write a Python program to make a chain of function decorators (bold,
italic, underline etc.) in Python
7 Write a Python program to generate a random alphabetical character,
alphabetical string and alphabetical string of a fixed length.
Use random.choice()
8 Write a generator function to print the table of the given number.
9 Write a python program to create University package which contains
result modules. Also create sub-package College which contains exam
module.
Create test module and add getdata() and display() and access
University and College package in it.
Note: Assume suitable data.
10 Create a child class Bus that will inherit all of the variables and methods
of the Vehicle class
11 Create a Bus class that inherits from the Vehicle class. Give the capacity
argument of Bus.seating_capacity() a default value of 50.
Create a Bus child class that inherits from the Vehicle class. The default
12 fare charge of any vehicle is seating capacity * 100. If Vehicle is Bus
instance, we need to add an extra 10% on full fare as a maintenance
charge. So total fare for bus instance will become the final amount =
total fare + 10% of the total fare.
Write a Python class named Student with two attributes student_name,
13 marks. Modify the attribute values of the said class and print the original
and modified values of the said attributes.
Write a Python program to match a string that contains only upper and
14 lowercase letters, numbers, and underscores.
15 Write a python program to validate the password by using regular
expression.
a. Complexity requirement is that we need at least one capital letter, one
number and one special character.
b. We also need the length of the password to be between 8 and 18
16 Write a python program to validate the URL by using regular
expression.
17 Write a python program to validate an email address by using regular
expression.
18 Write a python program which consists of - try, except, else, finally
blocks.
19 Write a python program which raises the exception with a message.
20 Write a python program to accept age from user, raise user defined
exception if age is below 18 years.
21 Write a Python multithreading program to print the thread name and
corresponding process for each task (assume that there are four tasks).
22 Write a Python multithreading program which creates two threads, one
for calculating the square of a given number and other for calculating
the cube of a given number.
23 Given a file called myfile.txt which contains the text: “Python is object
oriented programming language”. Write a program in Python that
transforms the content of the file by writing each word in a separate line.
24 Write a Python program that displays the longest word found in a text
file.
25 Write a function in python that allows you to count the frequency of
repetition of each word found in a given file.
26 Write a Python program which allows you to extract the content of a file
from the 3rd line to the 7th line and save it in another file called
extract_content.txt.
27 Create the following DataFrame Sales containing year wise sales figures
for five salespersons in INR. Use the years as column labels, and
salesperson names as row labels.
2018 2019 2020 2021
Kapil 110 205 177 189
Kamini 130 165 175 190
Shikhar 115 206 157 179
Mohini 118 198 183 169

1. Create the DataFrame.


2. Display the row labels of Sales.
3. Display the column labels of Sales.
4. Display the data types of each column of Sales.
5. Display the dimensions, shape, size and values of Sales.
28 Plot the following data on a line chart and customize the chart
according to the below-given instructions:
Month January February March April May
Sales 510 350 475 580 600
Weekly Sales Report
1. Write a title for the chart “The Monthly Sales Report“
2. Write the appropriate titles of both the axes
3. Write code to Display legends
4. Display blue color for the line
5. Use the line style – dashed 6. Display diamond style markers on data
points
29 Observe following data and plot data according to given instructions:
Batsman 2017 2018 2019 2020
Virat Kohli 2501 1855 2203 1223
Steve Smith 2340 2250 2003 1153
Babar Azam 1750 2147 1896 1008
Rohit Sharma 1463 1985 1854 1638
Kane Williamson 1256 1785 1874 1974
Jos Butler 1125 1853 1769 1436

1. Create a bar chart to display data of Virat Kohli & Rohit Sharma.
2. Customize the chart in this manner
2.1 . Use different widths
2.2. Use different colors to represent different years score
2.3. Display appropriate titles for axis and chart
2.4. Show legends
2.5. Create a bar chart to display data of Steve Smith, Kane Williamson
& Jos Butler. Customize Chart as per your wish.
2.6. Display data of all players for the specific year.
30 Write a program to create a 3*3 numpy array with all the elements as
per the user choice and print the sum of all elements of the array
31 Write a program to perform basic arithmetic operations on 1D and 2D
array.
32 Write a Menu Driver Program to add, display, update, delete and exit in
a student database containing Student_id,Student_name,Course through
Python-MongoDB connectivity.
33 Demonstrate step by step MongoDB connection in Python
34 Write a Menu Driver Program to add, display, search, sort and exit in
book database containing

Book_id, Book_name, Book_author through Python-MongoDB


connectivity

You might also like