Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Class 12 CSC Practical Record File 2024-25 Final

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

DELHI PUBLIC SCHOOL BANGALORE NORTH

2024-2025

COMPUTER SCIENCE
(083)

PRACTICAL RECORD FILE

NAME:

CLASS: XII SEC


DELHI PUBLIC SCHOOL BANGALORE NORTH

CERTIFICATE
This is to certify that _________________________________ of
class XII bearing Board Examination Roll No.: _____________
has successfully completed the Practical Record File during the
academic year 2024-2025 in partial fulfillment of SSCE Practical
Examination for the subject COMPUTER SCIENCE (083)
conducted by CBSE

Date:

Internal Examiner Principal Signature

External Examiner

2
Computational Thinking and Programming – II
(PYTHON)
FUNCTIONS

1) Write a program to have following functions:

a) A function that takes a number as a parameter and calculates the cube for it. The function does not
return a value. If there is no value passed to the function in the function call statement as an
argument, the function should calculate and print the cube of 2

b) A function that takes two strings as arguments and return True if both the strings are equal otherwise
returns False

2) Write a function that has two numeric parameters and generates a random number between those two
numbers. Using this function, the main program should be able to print three numbers randomly.

3) Write a function that receives two string arguments and checks whether they are the same length strings
(return True in this case otherwise False). Write Function Call statement and display “Same Length” or “Not
Same Length” based on the result received from the function.

4) Write a function that takes a number n and then returns a number that has maximum face value in unit’s place.
Example: if numbers passed are 491 and 278, then the function will return 278.

5) Define a function named LINEARSEARCH (lst,k) that accepts a list lst and key to be searched k as
parameters, Implements linear search to find all occurrences of k in lst and returns another list containing all
the indexes/positions where k is found in lst. The function should return None if k is not found in lst. Write
an appropriate function call statement and print the result accordingly.

6) Define a function that accepts a list of numbers as a parameter, find and print the sum and the average of all
elements. Write an appropriate function call statement and print the result accordingly.

7) Define a function that takes two lists as parameters and create a third list that contains the elements from both
the lists and sort it in ascending order. Write an appropriate function call statement and print the result
accordingly.

8) Write a function part_reverse(<list>,start, end) to reverse elements in a part of the list passed as a parameter
to the function. The parameters start and end are the starting and ending index of the part of the list which
must be reversed.
Assume that start < end, start>=0 and end<len(list)
Sample Input Data of List
my_list=[1,2,3,4,5,6,7,8,9,10]
Function Call = part_reverse(my_list,3,6)
Output is
my_list=[1,2,3,7,6,5,4,8,9,10]
9) Define a function named Unit_Seven(*n) that takes variable length parameters. The function should find and
return a list of all values of input parameters that are ending with the digit seven. Write appropriate top level
statements to call the function and to display the list obtained as result
Sample Function call:
L=Unit_Seven(127,200,400,207,17,-127)
After the execution L will have [127,207,17,-127]
10) Write a user defined function to check the validity of a password string passed as a parameter. The function
returns True if all the Validation Rules given below are satisfied otherwise it returns False.

Validation Rules:

Given password must have

● At least 1 letter between [a-z] and 1 letter between [A-Z].


● At least 1 number between [0-9].
● At least 1 character from [$#@].
● Minimum length of 5 characters and Maximum length of 15 characters.
Write appropriate top level statements to accept a password from user, check and print whether the password
is Valid or Invalid by using the value returned by the above user defined function.

DATA FILE HANDLING

Topic: Text File Handling


1) Write a function in python to read and print an entire text file named Sample1.txt
2) Define a function named Alternate_Char() in python to print alternate characters from the
text file named sample.txt
3) Write a program to print all the digits in a text file.
4) Define a function named CharCount(ch) to count the frequency of a specific character
(accept from the user)in the file count.txt.
5) Write a Python program to count the number of lines in a text file.
6) Write a program to read the first n lines of a file poem.txt
7) Write a program to print the lines of a file poem.txt along with line number.
8) Write a function in python to print alternate line of a text file try.txt
9) Write a Python program to read a random line from a file
10) Write a Python program to read last n lines of a file.
11) Write a Python program to read a file line by line and store it into a list.
12) Write a program to print the line with maximum length in a file.
13) Write a Python program to count the frequency of words in a file
14) Write a python program to find and print the longest word in the text file “words.txt”.
15) Write a python program to count and print the number of times the following words appear
in the text file “Words.txt” :- a) “and” b) “is”
16) Write a program to display the contents of a text file “file1.txt” with all the words capitalized.
17) Write a program to write n lines into text a file “lines.txt” using write function
18) Write a program to write a list containing strings into a text file “write_lines.txt”
19) Write a program to copy the contents of “text1.txt” into another file “text2.txt”
20) Write a program to copy the contents of “try.txt” into “final.txt”. While copying the content
from the text file “try.txt” into “final.txt” append “#” after each and every character.
21) Write a program to create a new file named “new.txt” by removing lines that begin with
lowercase characters from “old.txt”
22) Write a program to create a new file named “new.txt” by removing lines that end with an
uppercase letter from “old.txt”
23) Write a program to create a new file named “word_new.txt” from “word_old.txt” by copying
only those words which are five characters in length.

4
24) Assuming that a text file “poem.txt” has some content, write a program to create “file2.txt”
that contains only those words from the file “poem.txt” that do not start with an uppercase
vowel.
25) Accept the names of players for two teams into the files named “Team1.txt” and “Team2.txt”
respectively with each team having 6 players. Create a new file named “FinalTeam.txt” which
has alternate names from “Team1.txt” and “Team2.txt”
Team1.txt Team2.txt FinalTeam.txt
Suman Yash Suman
Kiran Ranjan Ranjan
Bheem Jagan Bheem
Ram Mohan Mohan
Tom Rajesh Tom
Harry Suresh Suresh
26) Write a program to open the file “new.txt” created in question number 22 and add all the words
of file named “sample.txt” that start with 't' or 'T' (Note: Existing content of “new.txt” must be
retained)
27) Write a Menu Based Python program to count the number of spaces, digits, words and lines
from a text file called “D:\Exam\word.txt”. The menu should be
1. Add fresh contents to file
2. Display (contents of file & counters)
3. Exit
28) Write a Menu Based Python Program to count the number of uppercase letters and digits from
a text file called “word.txt”. Also make a copy of the file into “word2.txt”. The menu should be.
1. Add fresh contents to file
2. Make a Copy of the file
3. Display (contents of original file, copied file & counters)
4. Exit

29) Write a program to perform the following operations according to the sequence of steps given
below.
1. Open and display the contents of a file whose location is entered by the user.
2. Call a user defined function named ReplaceAll(oldword, newword) that
changes all the occurrences of oldword with newword in the file opened above and
returns the changed content. (Note: oldword and newword are entered by the user
and are passed to the functions as arguments)
3. Display the changed content.

30) Write a program to perform the following operations according to the sequence of steps given
below.
1. Accept n names from the user and store in a text file named “nameslist.txt”
2. Display the contents of the file “nameslist.txt”
3. Create a new file named “lexical_nameslist.txt” that stores the names of “nameslist.txt”
sorted lexicographically (i.e. alphabetic order)
4. Display the contents of “lexical_nameslist.txt”

5
Topic: Binary File Handling

1) WAP to write a tuple of 5 elements into a binary file named tupbin.dat. Also read and display
the contents of tupbin.dat
2) WAP to store n random numbers of 4 digits each in a list named pwdlist. Write the contents of
the list pwdlist into a binary file. Also read and display the binary file contents.
3) Write a program to create a binary file called emp.dat and write into it the employee details of
n employees available in the form of dictionaries.
For Ex. D= {empNo:"123", ename:"Ajay”, Salary: 50000}
4) Write a program to open the file “Emp.dat” (created in program 3), read the objects written in it
and display them.
5) Consider the following definition of a dictionary traTicket
traTicket={tnum: _____________ , source : _____________ ,
destination: _____________ ,cost: _____________}
Write definitions for the following user defined functions
a) def insert(filename) : To insert a dictionary object into the file passed as the
parameter.
b) def displayall(filename) : To display all the records stored in the file passed as
the parameter. (Display appropriate messages if file doesn’t exist or if there are zero records)
c) def search(filename, kTnum) : To find and display all the contents in a pickled
file passed as parameter, where tnum key of the dictionary is matching with the value passed
as kTnum
d) def modify_withtemp(filename, kTnum) : To find and modify all the records
in a pickled file passed as parameter, where tnum key of the dictionary is matching with the
value passed as kTnum (Using Temporary File)
e) def modify_withouttemp (filename, kTnum) : To find and modify all the
contents in a pickled file passed as parameter, where tnum key of the dictionary is matching
with the value passed as kTnum (without Using temporary File)
f) def Delete_withtemp(filename, kTnum) : To find and delete all the records in
a pickled file passed as parameter, where tnum key of the dictionary is matching with the value
passed as kTnum (Using Temporary File)
Create a Menu as follows and invoke the required function defined above to execute the task
chosen by the user.
MENU:
1. Insert a New Ticket Record (Retain previous data)
2. View all Records
3. Search a particular Ticket
4. Modify Ticket Details (Using Temporary File)
5. Modify Ticket Details (Without Using Temporary File)
6. Delete a record
7. Exit
6) Write required function definitions and menu options to implement the following additional
functionalities to above program
a) To delete all records where the Source is “Delhi” and “Destination” is “Mumbai”.
Display appropriate messages if the record doesn’t exist.
b) To display the number of records in the file
c) To increase the cost of all tickets by 20%
6
Topic: CSV File Handling
1) Write definitions for the following user defined functions
a) def Write_info() : To insert a record into a csv file named “Product.csv”
(Ensure that the header row is written only once into a file) with the following details:
[prod_id ,prod_name, prod_price, prod_qty] with ;(semicolon as delimiter)
b) def Read_info() : To display all the records stored in the csv file passed as the parameter.
(Display appropriate messages if file doesn’t exist or if there are zero records)
Create a Menu as follows and invoke the required function defined above to execute the task
chosen by the user.
MENU:
1. Insert a New Record (Retain previous data)
2. View all Records
3. Exit
2) Write a Python program
a) To write a nested list(with 3 records) with the following details
[M_type,M_name,M_price] to a
“Medicine.csv” in one go. (M_type takes the value “safe ” and “unsafe”)
b) After writing the content to “Medicine.csv” file read and display the content.
3) From the CSV file created in the above program “Medicine.csv”
a) Display only those records where type is “unsafe”
b) Display only those records M_price is more than 400
c) To display the number of records in the file(don’t count the header row).
4) Write a Python program to copy the contents of above file “Medicine.csv” into “Temp.csv”, but
with a different delimiter.
5) Write a program that reads a csv file and creates another csv file with the same content
except those records where the type is “safe”
6) Read the records from "Medicine.csv" file and display alternate records.
7) Write a program that reads a csv file and creates another csv file with price field value
Increased by 20% for all the medicines where the type is unsafe.

DATA STRUCTURES
1) Write a Menu Based Program to implement a stack that holds list of numbers. Take care of
overflow/underflow situations. The Menu should be
1. Push
2. Pop
3. Display entire stack content
4. Display Top Node
5. Exit
2) Write a menu driven python program to implement operations on STACK named L that stores a
list of numbers. Define the required functions as per the specifications given below
a) def PUSHSTACK (STK, N): where the numeric value N is pushed into the stack. If the size
of the stack is 10 report STACK OVERFLOW situation.
b) def IS_EMPTY (STK): returns True if stack is empty otherwise returns False
c) def POPSTACK (STK): where, the function returns the value deleted from the stack.
d) def SHOWSTACK(STK): displays the contents of the stack
7
e) def PEEK(STK): displays the topmost element of the stack
Write the required top-level statements and function call statements. Note the POPSTACK,
SHOWSTACK and PEEK functions will invoke IS_EMPTY function to check and report
STACK UNDERFLOW situation.
3) Write a Menu Based Program to implement a stack that holds details of books. Take care of
overflow/underflow situations. The Menu should be
1. Push
2. Pop
3. Display entire stack content
4. Display Top Node
5. Exit
Each node of the Stack will have the following structure
[BOOK_ID, TITLE, AUTHOR, PRICE]
4) Write the definition of a function POP_PUSH ( LPop, LPush, N) in Python. The function
should Pop out the 1ast N elements of the list LPop and Push them into the list LPush .
For example:
If the contents of the list LPop are [10, 15, 20, 30]
And value of N passed is 2,
then the function should create the list LPush as [ 30, 20]
And the list LPop should now contain [10, 15]
NOTE : If the value of N is more than the number of elements present in LPop, then display the
message "Pop not possible" .
Write the required top-level statements and function call statements and execute the program.

8
Database Management
Write SQL Queries for the following:

1) Create a Database named INSTITUTE


2) Create a table named FACULTY with the following structure.
Table FACULTY
ATTRIBUTE DATATYPE CONSTRAINT
F_ID Integer PRIMARY KEY
Fname Text data with max length 25 characters NOT NULL
NOT NULL and
Lname Text data with max length 25 characters UNIQUE
HIRE_DATE DATE
SALARY DECIMAL SIZE 7,2 Must be >= 5000

3) Create a table named COURSES with the following structure.


Table : COURSES
ATTRIBUTE DATATYPE CONSTRAINT
C_ID Text(10) PRIMARY KEY
F_ID Integer Foreign Key
CNAME TEXT SIZE 40 CHARS DEFAULT VALUE “BASIC COURSE”
FEES DECIMAL SIZE 7,2

4) Insert following data records into FACULTY table and COURSES table.

5) To display all records from FACULTY table


6) To display all records from COURSES table
7) To display all records from FACULTY table whose Hire date is more than 05-OCT-2001
8) To display F_ID, Fname, Cname of those faculties who charged more than15000 as fees.
9
9) Display faculty id and the count of number of courses handled by each faculty from
courses table
10) Display all records FACULTY table order by First Name of the faculty in descending order
11) Display Faculty id,faculty name,Salary and course name from faculty and courses table
12) To increase the fees of Dreamweaver course by 500.
13) Alter COURSES table to change size of CNAME field to varchar(50)
14) Alter FACULTY table to add a new field to Phone Number varchar(15)
15) Display distinct F_ID from COURSES table.
16) Display records from FACULTY table where Last name starts with ‘M’
17) Display today’s date
18) Display total and average fees from COURSES table.
19) Display Faculty names from FACULTY table who handle/teach more than one
Course(Nested Query)
20) Display all records from FACULTY table whose phone number is NULL
21) Show the structure of FACULTY table and COURSES table
22) Delete records from COURSES table having F_ID as 102
23) Delete all records from COURSES table
24) Revoke the last delete operation
25) Drop COURSES table.
26) Write the outputs of the SQL queries (a) to (d) and write the SQL queries for (e) to (h)
based on the relations SCHOOL and ADMIN given below:

a) SELECT TEACHERNAME,PERIODS FROM SCHOOL WHERE PERIODS < 25


ORDER BY TEACHERNAME;
b) SELECT TEACHERNAME, ADMIN.CODE, GENDER FROM SCHOOL, ADMIN
WHERE SCHOOL.CODE = ADMIN.CODE AND GENDER LIKE 'FEMALE';
c) SELECT TEACHERNAME,DESIGNATION FROM SCHOOL, ADMIN WHERE
SCHOOL.CODE = ADMIN .CODE AND SUBJECT LIKE 'ENGLISH';
d) SELECT SUBJECT, PERIODS FROM SCHOOL GROUP BY SUBJECT HAVING
MIN(PERIODS);
e) Display Code, Teachers name , Designation and experience from school table and admin
table whose experience is more than 10 years
10
f) Add the details of a new teacher in school table . Details are as follows
(1011,VEENA, COMPUTER SCIENCE,12/07/2000,25)
g) To remove the details of all HODs from the ADMIN table
h) Increase the number periods by 2 for all the teachers handling PHYSICS

PYTHON MYSQL CONNECTIVITY


1) Write a Menu Based Python database connectivity script that performs the following operations
on the table named PRODUCT in SHOP Database. Observe the data given and set suitable
primary key for the table and appropriate datatypes for the fields.
Table: PRODUCT
P_ ID ProductName Manufacturer Price
TP01 Talcum Powder LAK 40
FW05 Face Wash ABC 45
BS01 Bath Soap ABC 55
SH06 Shampoo XYZ 120
FW12 Face Wash XYZ
The Menu should be
1. Add a record
2. Display All Records
3. Display records of a particular manufacturer.
4. Modify the Price of a given P_ID entered by user.
5. Delete a Record of given ProductName
6. Exit.

11

You might also like