0% found this document useful (0 votes)
21 views

Computer Practical - Final

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Computer Practical - Final

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

Computer Practical Work

NAME: DIVYANSH SRIVASTAVA


CLASS: XII
ROLL NO:
SESSION: 2024-25

1|Page
CERTIFICATE

This is to certify that DIVYANSH

SRIVASTAVA of Class: XII has successfully

completed the laboratory work in COMPUTER

SCIENCE(083) PYTHON under the guidance of Mrs.

Seema Agarwal during the year 2024-25 in the

partial fulfilment of the Computer practical

examination conducted by the CBSE.

SIGN OF EXTERNAL EXAMINER SIGN OF TEACHER

2|Page
Index
S. No. Program Page No. Signature
1 WAP to perform the various operations in the form of 6
calculator using functions.
2 Write a function EOReplace() in python, which accepts 6
a list of numbers, thereafter it increments all the even
numbers by 1 and decrements all the odd numbers by
1.
3 Write a Python program to create a function to find 7
the area of a triangle given the lengths of all three
sides
4 Write a function which accepts a string and calculates 7
the total number of uppercase, lowercase, digits in a
string
5 Write a program to count a total number of lines and 7
count the total number of lines starting with 'A', 'B',
and 'C' from the file myfile.txt.
6 Add the following lines to the end of the file to indicate 8
the end of the file and the end of the file is reached
7 Write a program to read data from a text file and write 8
it into a binary file. Additionally, implement error
handling to ensure that the program can gracefully
handle any potential issues such as file not found,
permission denied, or corrupted data.
8 Write a program to convert a given list of numbers into 9
a dictionary with keys being the numbers and values
being their corresponding Fibonacci numbers. The
program should also handle cases where the given list
contains negative numbers or non-integer values.
9 Write a program to read a text file and count the 9
number of occurrences of each word. The program
should ignore punctuation marks and consider words
with different capitalizations as the same word.
Additionally, the program should display the top 10
most frequently occurring words in descending order.
10 Write a python program to accept username "Admin" 10
as default argument and password 123 entered by user
to allow login into the system.
11 Write a Python program to accept a list as a function 10
parameter and raise the IndexError exception.
12 Write a program to write data into binary file 11
marks.dat and display the records of students who
3|Page
scored more than 95 marks.
13 Write a program to write and read data from 11
student.dat file and display the records of students
whose age is greater than 18.
14 Write a Python program to calculate the sum of all the 12
elements in a given list.
15 Write a Python program to check if a given number is a 12
prime number.
16 Write a python program to check whether a string is a 12
palindrome or not using stack.
17 Write a function in python to display the elements of 13
list thrice, if it is a number; else terminate it with "#".
18 Consider the following MOVIE table and write the 13, 14, 15
corresponding SQL queries.
a) Display all the movie information.
b) Display the types of movies.
c) Display movieid, moviename, total_earning by
showing the business done by the movies. Calculate
the business done by movie using the sum of
productioncost and businesscost.
d) Display movieid, moviename and productioncost for
all movies with productioncost greater than 150000
and less than 1000000.
e) Display the movie of type action and romance.
f) Display the list of movies that are going to release in
February, 2022.
19 Consider the table patient and write the following 15
queries.
a) Count the unique departments.
b) Display the average charges.
20 Suppose your school management has decided to 16, 17
conduct cricket matches between students of Class XI
and Class XII. Students of each class are asked to join
any one of the four teams - Team Titan, Team Rockers,
Team Magnet and Team Hurricane. During summer
vacations, various matches will be conducted between
these teams. Help your sports teacher to do the
following:
a) Create database “sports”.
b) Create a table "TEAM" with following
considerations:
4|Page
a. It should have a column TeamID for storing an
integer value between 1 to 9, which refers to
unique identification of a team.
b. Each TeamID should have its associated name
(TeamName), which should be a string of length not
less than 10 characters.
c. Using table level constraint, make TeamID as the
primary key.
c) Display the structure of the table team.
d) As per the preferences of the students four teams
were formed as given below. Insert these four rows in
TEAM table:
a. Row 1: (1, Tehlka)
b. Row 2: (2, Toofan)
c. Row 3: (3, Aandhi)
d. Row 3: (4, Shailab)
e) Show the contents of the team table.
21 Write the code to: 17
1. Retrieve the data.
2. Insert data
22 Create a table ‘emp’ through MySQL-Python 18
connectivity.
23 Input a record in table “emp” through MySQL-Python 19
connectivity.
24 Update record(s) of the EMP table using UPDATE 19, 20
through MySQL-Python connectivity.
25 Delete record(s) from EMP table using DELETE through 20, 21
MySQL-Python connectivity.

5|Page
Q1. WAP to perform the various operations in the form of
calculator using functions.

Q2. Write a function EOReplace() in python, which accepts a


list of numbers, thereafter it increments all the even numbers
by 1 and decrements all the odd numbers by 1.

6|Page
Q3. Write a Python program to create a function to find the
area of a triangle given the lengths of all three sides.

Q4. Write a function which accepts a string and calculates the


total number of uppercase, lowercase, digits in a string

Q5. Write a program to count a total number of lines and count


the total number of lines starting with 'A', 'B', and 'C' from the
file myfile.txt.

7|Page
Q6. Add the following lines to the end of the file to indicate the
end of the file and the end of the file is reached

Q7. Write a program to read data from a text file and write it
into a binary file. Additionally, implement error handling to
ensure that the program can gracefully handle any potential
issues such as file not found, permission denied, or corrupted
data.

8|Page
Q8. Write a program to convert a given list of numbers into a
dictionary with keys being the numbers and values being their
corresponding Fibonacci numbers. The program should also
handle cases where the given list contains negative numbers or
non-integer values.

Q9. Write a program to read a text file and count the number
of occurrences of each word. The program should ignore
punctuation marks and consider words with different
capitalizations as the same word. Additionally, the program
should display the top 10 most frequently occurring words in
descending order.

9|Page
Q10. Write a python program to accept username "Admin" as
default argument and password 123 entered by user to allow
login into the system.

Q11. Write a Python program to accept a list as a function


parameter and raise the IndexError exception.

10 | P a g e
Q12. Write a program to write data into binary file marks.dat
and display the records of students who scored more than 95
marks.

Q13. Write a program to write and read data from student.dat


file and display the records of students whose age is greater
than 18.

11 | P a g e
Q14. Write a Python program to calculate the sum of all the
elements in a given list.

Q15. Write a Python program to check if a given number is a


prime number.

Q16. Write a python program to check whether a string is a


palindrome or not using stack.

12 | P a g e
Q17. Write a function in python to display the elements of list
thrice, if it is a number; else terminate it with "#"

Q18. Consider the following MOVIE table and write the


corresponding SQL queries.

a) Display all the movie information.

13 | P a g e
b) Display the types of movies.

c) Display movieid, moviename, total_earning by showing the


business done by the movies. Calculate the business done by
movie using the sum of productioncost and businesscost.

d) Display movieid, moviename and productioncost for all


movies with productioncost greater than 150000 and less than
1000000.

e) Display the movie of type action and romance.

14 | P a g e
f) Display the list of movies that are going to release in
February, 2022.

Q19. Consider the table patient and write the following


queries.

c) Count the unique departments.

d) Display the average charges.

15 | P a g e
Q20. Suppose your school management has decided to conduct
cricket matches between students of Class XI and Class XII.
Students of each class are asked to join any one of the four
teams - Team Titan, Team Rockers, Team Magnet and Team
Hurricane. During summer vacations, various matches will be
conducted between these teams. Help your sports teacher to
do the following:
a) Create database “sports”.

b) Create a table "TEAM" with following considerations:


a. It should have a column TeamID for storing an integer
value between 1 to 9, which refers to unique identification
of a team.
b. Each TeamID should have its associated name
(TeamName), which should be a string of length not less
than 10 characters.
c. Using table level constraint, make TeamID as the primary
key.

c) Display the structure of the table team.

16 | P a g e
d) As per the preferences of the students four teams were
formed as given below. Insert these four rows in TEAM table:
a. Row 1: (1, Tehlka)
b. Row 2: (2, Toofan)
c. Row 3: (3, Aandhi)
d. Row 3: (4, Shailab)

e) Show the contents of the team table.

Q21. Write the code to:


3. Retrieve the data.

4. Insert data.

17 | P a g e
Q22. Create a table ‘emp’ through MySQL-Python connectivity.

18 | P a g e
Q23. Input a record in table “emp” through MySQL-Python
connectivity.

Q24. Update record(s) of the EMP table using UPDATE through


MySQL-Python connectivity.

19 | P a g e
Q25. Delete record(s) from EMP table using DELETE through
MySQL-Python connectivity.

20 | P a g e
Output:
>>> Enter salary whose record to be deleted: 80000
1 record(s) deleted

21 | P a g e

You might also like