0% found this document useful (0 votes)
42 views7 pages

Class 12 Practical Record Programs

Cbse project
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views7 pages

Class 12 Practical Record Programs

Cbse project
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

CLASS – XII

COMPUTER SCIENCE
RECORD PROGRAM QUESTIONS- 25-26

Instruction:
 Program should be in the following order
o Program title
o Problem Description
o Source code
 Should be on the right-hand side
 Output screen shot on left-hand side
 Each program should start in a new page.
 Print – back-to-back.
o Document should be spiral bound.
 The order of the document
o Front page
o Bonafide
o Index page (Attached-to be typed not handwritten)
o Source code with output

EX.NO.01 Write a menu driven program to Manipulate Strings –


Separate URL
A) A function SEP_URL(url) in python to accept an URL of a web page as
argument and return the different parts of it as multiple values.
Replace String
B) A function Replace_Str(S1) in python, that accepts the given text as argument and
replace the word ‘sad’ with ‘happy’ in the first 2 occurrences and replace ‘news’ with
‘information’ only in the first occurrence of the text.
Display Common words
C) To write a function COMMON(S1,S2) in python to accept 2 strings as arguments
and to find the common words in both the strings.

EX.NO.02 Menu Driven for the following:


i) Write a UDF to check if a number is Automorphic (a number whose
square ends with the same digits, e.g., 25 → 25²=625). The function
should return a string ‘Yes the number is Automorphic number’ otherwise
‘No the number is not an Automorphic number’
ii) Write a UDF to find the Twin primes numbers: (A pair of prime numbers
that have a difference of 2). Example: (3, 5), (11, 13), (41, 43).

EX.NO: 03 Write a menu driven program to manipulate List –


Store Indices of Non-Zero elements
A) A function INDEX_LIST(L) in python, where L is the list of elements passed as
argument to the function. The function returns another list named ‘IndexList’ that
stores the indices of all Non-Zero Elements of L.
For example: If L contains [12,4,0,11,0,56]. The IndexList will have [0,1,3,5]
Double the Odd values
B) A function DoubletheOdd( ) in python to add and display double the sum of odd
values from the list, NumList.
For example: If the NumList contains [25,24,35,20,32,41] .
The function should display Double of Odd Sum: 202

EX.NO: 04 Write a menu driven program to manipulate List


Store Indices of 4 lettered words
A) A function lenFOURword(L) in python, where L is the list of elements
(list of words) passed as an argument to the function. The function returns another
list
named ‘indexedList’ that stores the indices of all four lettered word of L.
Swap adjacent elements
B) A function SwapAdjacent(nums) in python, that accepts a list as
argument and interchanges the adjacent elements and print both the original list and
the modified list.

EX.NO:05 Write a menu driven program to Manipulate List


Find the Longest Word
A) A function Longest_Word(Words_list)in python that accepts a list of words as an
argument and returns the longest word from the list with its length.
Shifting the elements to left
B) A function Lshift(L,N) in python, where L is the list of elements passed as an
argument to the function. The function shifts all the elements by N places to the left
and then print it.For example: If L contains [9,4,0,3,11,56] and N=2
The function will print [0,3,11,56,9,4]

EX.NO:06 “Guess the Number Game” using random module


To write a python program to implement “Guessthe NumberGame” using random
module.

EX.NO.07 Pattern generation & Manipulate Student Marks in Nested Tuples


A) A function PatternGen(): to generate the following pattern:
12345
21234
32123
43212
54321
B) A program to create a nested tuple to store student marks in 5 subjects
and a function calc(m) to display the total and average of their marks.

EX.NO.08 Manipulating Dictionary using Functions


To write a menu driven python program with user defined functions to manipulate
(add/search/update/delete) dictionary of list containing customer details
(Cid/Cname/Ccity/). Note: Manipulation should be based on keys.

EX.NO.09: TEXT FILES IN PYTHON - Count the occurrences of word


A) To write a UDF RainCount() in Python, which should read the content of a text
file ‘TESTFILE.TXT’ and then count and display the number of occurrence of word
RAIN (case-insensitive) in the file.
To Count number of vowels and consonants
B) To write a function Vowels() in Python, which should read the content of a text
file ‘TESTFILE.TXT’ and then count and display the number of vowels and
consonants present in the file.

EX.NO.10 TEXT FILES IN PYTHON - Count the lines starts with A/B
A) To write a function Countlines()in Python to read a text file ‘Poem.txt’ and count
and display the number of lines starts with ‘A’ / ‘B’ separately.
To display the lines with exactly 6 words
B) To write a function ShowLines()in Python, that would read the contents of a text
file‘Poem.txt’ and display only those lines which contains exactly 6 words in it.

EX.NO.11: TEXT FILES IN PYTHON - Copying lines to a new file


A) Write a function Filter(oldfile,newfile) in Python that would read the contents of
the file ‘source.txt’ and copy only those lines which does not contain ‘@’ sign in it to
a new text file ‘target.txt’.
To replacing the ‘-‘ sign with a blank space
B) Write a function Replace() in Python to read the text file ‘Source.txt’ and to
replace the ‘-‘ sign with blank space in all the occurrences.

EX.NO.12 TEXT FILES IN PYTHON -Remove duplicate lines from the file &
Display unique words present in the file

A) Write a function RemoveLines() in Python that would read the contents of the file
‘Poem.txt’ and remove the duplicate lines from the file.

B) Write a function UniqueWord() in Python to read the text file ‘Stars.txt’ and to
display the unique words from the file.

EX.NO:13 WORKING WITH BINARY FILE IN PYTHON- Create a binary


file, Search and display the records from the binary file.
(i) To write a user defined function CreateFile() to input the records and add to the
binary file ‘Books.dat’ which has the structure [Book_ID, Book_Name, Author,
Price].

(ii) To write a function CountRec(Author) which accepts the Author name as


parameter and the function should return the book names and number of books by the
author stored in the binary file ‘Books.dat’
EX.NO:14 WORKING WITH BINARY FILE IN PYTHON- Create a binary
file, Update and display the records from the binary file

(i) To write a user defined function AddData() to input and add the records to the
binary file ‘Employee.dat’ which has the structure { ‘EmpCode’: , ‘EmpName’:
‘Desig’:, ‘Salary’:}

(ii) To write a function UpdateRec(Desgn) which accepts the designation as


parameter and update the salary for the employees in the file ‘Employee.dat’. Also
display the
records from the file.

EX.NO:15 WORKING WITH BINARY FILE IN PYTHON


A) Write a function SaveProduct() that takes the following data [pno, pname, qty,
unitprice] from the user and stores into a file ‘product.dat’.
B) Write a function newProduct() that reads the above files and stores the top 5
priced product into another file ‘topProduct.dat’.
C) Remove all those products that are priced less than 2500 from the original file.

EX.NO:16 WORKING WITH CSV FILE IN PYTHON- Create a CSV file,


Search and display the records from the CSV file
(i) To write a user defined function Create() to input and add the records to the csv
file ‘Students.csv’ which has the structure [RollNo, Name, Marks].

(ii) To write a user defined function SearchRec(code) which reads and displays the
student records along with the total count who have secured above 80 from the file
‘Students.csv’.

EX.NO:17 WORKING WITH CSV FILE IN PYTHON


Create a CSV file, Update and display the records from the CSV file
(i) Write a function Create() to input and add the records to the csv file
‘Customers.csv’ which has the structure [Cust_ID,Cust_Name,City, Contact_No]

(ii) UpdateRec(id) to update the contact number of the customer for the customer id
given by the user. Display the records stored in the file Customers.csv

EX.NO:18 IMPLEMENTATION OF STACK USING LIST IN PYTHON


Consider a dictionary containing nonfiction book names and their ratings as key
value pairs as below.
Books={"Behind the beautiful forevers":8.5,"Omnivore's Dilemma":7,"Unnatural
Selection":6.5,"Guns, Germs and Steel":9,"Business Adventures":7.5,"The power of
Full engagement":9.5}
To write a python program with separate user defined functions to perform the
following operations.
(i) Push the keys (Book name) of the dictionary into the stack, where the
corresponding value (rating) is more than 8.
(ii) Pop and display the content of the stack.

Ex. No: 19 INTERFACING PYTHON WITH MYSQL


To write a database connectivity program in Python to establish connection to a
MySQL database ‘SCHOOL’ and to do the following.

i) Create a table ‘student’ with the following fields Rollno-integer(10),


primary key, Name varchar(30) not null, Class char(3), Marks
decimal(10,2)
ii) To insert the records into the table ‘student’
iii) To display all the records stored into the table ‘student’, sorted by student
name in descending order.

Ex. No: 20 INTERFACING PYTHON WITH MYSQL


To write a database connectivity program in Python to establish connection to a
MySQL database ‘SCHOOL’ and to do the following.
i) To update & display the marks of a ‘student’ for the given rollno taken as
user input.
ii) To display number of students in each class.

Ex. No: 21 INTERFACING PYTHON WITH MYSQL-


To write a database connectivity program in Python to establish connection to a
MySQL database ‘SCHOOL’ and to do the following.
i) To display all the records of the students who have secured marks in the
range of 80 to 100.
ii) To delete the records of all the ‘Student’ whose name contains letter ‘a’ in
the start and end. Also display the deleted records.

SQL Commands
1. To create a table EMPLOYEE with the following attributes:
ENO int, ENAME varchar(20),GENDER char,DEPTNO int, JOB varchar (15),
DOJ Date (Date of Joining), and SALARY float(7,2)
2. To add PRIMARY Key constraint to ENO
3. Write SQL statement to add 5 records into the relation EMPLOYEE
4. To add 2 tuples by specifying the attributes of the relation EMPLOYEE
5. To display all attributes of relation EMPLOYEE for the DEPTNO 10
6. To display ENO, ENAME and SALARY for all the tuples of the relation
EMPLOYEE
7. To display ENO, ENAME and GENDER in alphabetical order of ENAME
8. To display the maximum, minimum and average salary from the relation
EMPLOYEE
9. To display details of all the Employees whose salary is between 45,000 and
Rs.70,000, sorted in descending order of SALARY
10. To display dissimilar DEPTNO in ascending order
11. To increase the SALARY by Rs.3,500 for those working in DEPTNO 30
13. To increase the size of ENAME attribute by 5 bytes
14. To add a new attribute CONTACT to hold a 10-digit mobile number (Use char type)
14. To add NOT NULL constraint to Ename attribute
15. To display the DEPTNO and number of employees working in each DEPTNO
16. To display the DEPTNO and number of employees working in each DEPTNO, that
has at least two employees
17. To display Employee Names that has exactly four characters
18. To display ENAME that does not start with the letter “S”
19. To display department wise total amount spent on salary
20. To display number of male and female employees.
21. To remove a tuple(s) of those employees who work for the departments 10 and 20
(Use IN clause)
22. To remove the attribute DOJ from the table Employee
Assume the existence of the following relation DEPT:
TABLE: DEPT

DEPTNO DEPTNAME
10 ADMINISTRATION
20 FACTORY
30 PURCHASE
40 SALES
50 RESEARCH
23. Write SQL Command that displays ENO, ENAME, DEPTNO and DEPTNAME using
natural join of both the EMPLOYEE and DEPT tables
24. To remove all tuples of the relation EMPLOYEE
25. To remove the schema (or structure) of the relation EMPLOYEE
INDEX
S. No Title Page No
01

02

03

04

05

06

07

08

09

10

11

12

13

14

15

16

17

18

19

20

21

22 SQL Commands

Signature of the teacher In-charge

You might also like