2CS404 PSC Lop
2CS404 PSC Lop
2CS404 PSC Lop
Institute of Technology
B.Tech. Computer Science and Engineering
Practical List
Semester-IV
92 = 81, and 8 + 1 = 9
Practice Questions:
Statistical data:
i. Calculate a total score made by the player during the last 10 innings and
calculate the average.
ii. Count the no of time players score the run <50, >=50 and <100, >=100
and <150 and >=150
Sample Data:
P100012 101 9 8 7 14 NA NA NA NA 43
P000001 NA NA NA NA 10 63 45 00 10 34
P023401 10 12 4 6 NA NA NA NA NA NA
P679087 9 31 21 4 62 87 47 94 109 20
4. File Handling and exception; 04 1,2
a. Write a python program that reads the contents of the file poem.txt and count Hours
the number of alphabets blank spaces lowercase letters and uppercase letters
the number of words starting from vowel and the number of occurrences of
each word in the file.
b. An organization wants to compute monthly wages to be paid to an employee
in an organization. The input data is provided in two different files. File1
contains permanent employee data about employees (i.e. Empid, name, hourly
wages), and File2 contains working hours information of each employee in the
current month (i.e., empid and hours). Individual elements of data are
separated by commas. Design a python program that reads both the files,
computes the monthly wages of each employee and store in another file. Take
both file names as command line arguments and check the respected
exceptions for the same.
File Format:
File1
1001, Vinay kumar, 40
1002, Rohit sen, 35
1003, Vinita sharma, 28
File2
1001, 250
1002, 0
1003, 125
c. Consider the following formula and evaluate the y value for the range of t
values found in a file with format
𝑦(𝑡) = 𝑣0 𝑡 − 0.5𝑔𝑡 2
File Format:
v0 3.0
t:
0.15592 0.28075 0.36807889 0.35 0.57681501876 0.21342619 0.0519085
0.042 0.27 0.50620017 0.528 0.2094294 0.1117 0.53012 0.3729850
0.39325246 0.21385894 0.3464815 0.57982969 0.10262264 0.29584013
0.17383923
More precisely, the first two lines are always present, while the next lines
contain an arbitrary number of t values on each line, separated by one or more
spaces.
i. Write a function that reads the input file and returns v0 and a list with the
t values.
ii. Write a function that creates a file with two nicely formatted columns
containing the t values to the left and the corresponding y values to the
right. Let the t values appear in increasing order (note that the input file
does not necessarily have the t values sorted).
iii. Make a test function that generates an input file, calls the function for
reading the file, and checks that the returned data objects are correct.
iv. Write a function which handle the exception handling for the availability
of file or not.
Practice Questions :
d. Develop the Python program for the home loan portal as mentioned below:
The portal has following functionalities:
• Scan the user details from the user and store it to UserDetails.txt file.
Refer the below table for format of file.
Name of TEXT file: UserDetails.txt
Format of File:
UserID| UserCompleteName|Password|
HomeLoanAmount|RemainingLoanAmount
Sample Data
ajaypatel|Ajaykumar Patel|Passwordpw|3000000|2000000
bandish|Bandish Shah|Passwordpw|1000000|550000
darshan|Darshan Dave|Passwordpw|750000|700000
• Scan the Loan Payment Details from the user and store it to
LoanPaymentDetails.txt file.
Name of TEXT file: LoanPaymentDetails.txt
Format of File:
UserID|AmoutPaid|Description|DayOfMonth|Month|Year
Sample Data
ajaypatel|35000|April Payment|2|9|2020
bandish|15000|April Payment|7|9|2020
darshan|7500|April Payment|10|9|2020
ajaypatel|37000|May Payment|1|10|2020
bandish|16000|May Payment|3|10|2020
darshan|10000|May Payment|2|10|2020
• Display the summary details of loan repayment for each loan year-
wise.
Format of summary:
Year: <Year here>------------------------------
Name: <userID here>
Complete Name: < UserCompleteName here>
Home Loan Amount: < HomeLoanAmount here>
Current Remaining Loan Amount: < RemainingLoanAmount here>
Loan Repayment Amount in year <Year here>: <total of repayment>
------------------------------------------------------------
i.e.
Year: 2019------------------------------
Name: darshan
Complete Name: Darshan Dave
Home Loan Amount: 750000
Current Remaining Loan Amount: 740000
Loan Repayment Amount in year 2019: 17500
------------------------------------------------------------
Year: 2020------------------------------
Name: darshan
Complete Name: Darshan Dave
Home Loan Amount: 750000
Current Remaining Loan Amount: 700000
Loan Repayment Amount in year 2020: 17500
------------------------------------------------------------
• Display the summary details of loan repayment for each loan year-
wise month-wise.
Format of summary:
------------------------------------------------------------
--------------------------------------------------------------
5. a. Define a class Bank that keeps track of bank customers. The class should 02 1
contain the following data member:
Data member Details Hours
name
Name Name of customer
accountNum Account Number
type Account Type
amount Amount deposited in the bank account
interest Interest earned by the customer
The class should support the following methods:
(a) __init__ for initializing the data members.
(b) deposit for depositing money in the members.
(c) withdrawal for withdrawing money from the account
(d) findInterest that determines the interest on the basis of amount in the
account
Amount Interest per annum
(%)
>= 5,00,000 8
>= 3,00,000 and < 5,00,000 7
>=1,00,000 and <3,00,000 5
<1,00,000 3
b. Define a base class Person, having attributes name, birthdate and city.
Define the class Student that derives from Person class which is having
attributes like rollno, branch, totalMarks and year as data member. The class
should contain the instance method __init__ and the percentage with pass
statement. Define two classes Grad and PostGrad which inherit from the
base class Student. Both the classes should define their __init__ method
which asks user to enter totalMarks value and should override the method
percentage of the superclass. Note that totalMarks obtained are out of 600
and 400 for Grad and PostGrad classes respectively.
a. As you know, a magic square is a matrix all of whose row sums, column Hours
sums and the sums of the two diagonals are the same. (One diagonal of a
matrix goes from the top left to the bottom right, the other diagonal goes
from top right to bottom left.) Show by direct computation that if the matrix
A is given by
A=np.array([[17, 24, 1, 8, 15],
[23, 5, 7, 14, 16],
[ 4, 6, 13, 20, 22],
[10, 12, 19, 21, 3],
[11, 18, 25, 2, 9]])
The matrix A has 5 row sums (one for each row), 5 column sums (one for
each column) and two diagonal sums. These 12 sums should all be exactly
the same, and you could verify that they are the same by printing them and
“seeing” that they are the same. It is easy to miss small differences among
so many numbers, though. Instead, verify that A is a magic square by
constructing the 5 column sums and computing the maximum and minimum
values of the column sums. Do the same for the 5 row sums, and compute
the two diagonal sums. Check that these six values are the same. If the
maximum and minimum values are the same, the flyswatter principle says
that all values are the same.
b. Create scientific calculator using numpy and scipy API.
Matplotlib
c. Plot a line graph that shows in the figure for the given data. The runs scored
between two-wicket fall in a one-day international match between India and
England is generated using randomly. Example:
Fall of 1st 2nd 3rd 4th 5th 6th 7th 8th 9th 10th
Wicket
India 5 35 24 0 99 1 35 15 27 14
England 10 55 34 21 2 7 118 29 32 10
Plot:
7. Pandas: 02 2,3
Develop a python program that reads the data from a given CSV file, which Hours
is having phone usage data using a different branded mobile phone.
Determine if the usage patterns for users differ between different devices.
For example, do users using Samsung devices use more call minutes than
those using LG devices?
a. Develop a python program that reads the image, display matrix Hours
representation of an image creates a histogram of the image and apply
the smoothing effect on an image.
b. Develop a python program which takes the video as an argument and
extract all the frames from a video. Select specific frames and
recreate the video, which has selected frames only.
10. Develop a web page using Django, which asks to upload the CSV file and month 02 3
details from a user, which is having an attendance record of 50 employees of a
company. Display the attendance record in HTML tabular form, which is showing Hours
details like employeeID, a Total number of days, Present Days and percentage
details.
CSV details
E001, p,p,p,p,a,a,p……p
E002, p,a,p,p,p,p,p……p
E003, a,p,p,p,p,p,p……a
In HTML page the display looks like
EmpID Total Days Present Days Percentage
E001 30 26 86.67%
E002 30 25 83.33%
E003 30 20 66.67%