0% found this document useful (0 votes)
130 views5 pages

Class XII Computer Science Practicals

Uploaded by

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

Class XII Computer Science Practicals

Uploaded by

tambirashmi8
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Subject : Computer Science || Session : 2024-25 || Teacher : Sunil Nehra || Class : XII

PRACTICAL FILE - COMPUTER SCIENCE (083)


LIST OF PRACTICALS (2024-25)
Program 1: Give an example code to handle ZeroDivisionError? The code should display the
message "Division by Zero is not allowed" in case of ZeroDivisionError exception,
and the message "Some error occurred" in case of any other exception.
Program 2: What do you understand by local and global scope of variables? How can you access a
global variable inside the function if function has a variable with the same name?
Program 3: Write a Program to find factorial of entered number using user-defined function fact().
Program 4: 1. Differentiate between actual parameter(s) and a formal parameter(s) with a
suitable example for each.
Program 5: 2. Write the definition of a function Reverse(X) in Python, to display the elements in
reverse order such that each displayed element is the twice of the original
element (element * 2) of the List X in the following manner:
Example:
If List X contains 7 integers is as follows:

Program 6: Write a program with a user-defined function with string as a parameter which
replaces all vowels in the string with “*”.
Program 7: Read a text file and display the number of
vowels/consonants/uppercase/lowercase characters in the file.
Program 8: Write a Program to read data from data file in read mode and count the particular
word occurrences in given string, number of times in python.
Program 9: Write a function countNow(PLACES) in Python, that takes the dictionary, PLACES
as an argument and displays the names (in uppercase) of the places whose names
are longer than 5 characters.
For example, Consider the following dictionary
PLACES={1:"Delhi",2:"London",3:"Paris",4:"New York",5:"Doha"}
The output should be:
LONDON
NEW YORK
Program 10: Write a function, lenWords(STRING), that takes a string as an argument and
returns a tuple containing length of each word of a string. For example,
if the string is "Come let us have some fun", the tuple will have (4, 3, 2, 4, 4, 3)
Program 11: Write a function in Python to read a text file, Alpha.txt and displays those lines
which begin with the word ‘You’.
Program 12: Write a menu-driven program implementing user-defined functions to perform
different functions on a csv file “student” such as :
a) Write a single record to csv.
b) Write all the records in one single go onto the csv.
c) Display the contents of the csv file.

Subject : Computer Science || Session : 2024-25 || Teacher : Sunil Nehra || Class : XII
Subject : Computer Science || Session : 2024-25 || Teacher : Sunil Nehra || Class : XII
Program 13: Write a Python program to read specific columns from a “department.csv” file and
print the content of the columns, department id and department name.
Program 14: Create a binary file with name and roll number. Search for a given roll number
and display the name, if not found display appropriate message.
Program 15:
3. Write a function AMCount() in Python, which should read each character of a text
file STORY.TXT, should count and display the occurance of alphabets A and M
(including small cases a and m too).
Example:
If the file content is as follows:
Updated information
As simplified by official websites.
The EUCount() function should display the output as:
A or a:4
M or m :2
Program 16:
4. Write a random number generator that generates random numbers between 1
and 6 (simulates a dice).
Program 17: Consider a pickled file FACTORY.DAT that consists of a field FCTID. Write a
program in Python to search a record based on factory Id, i.e., if FCTID is matching
with the value–105, the entire record is to read from the file, and if found, should
call a Display() function to display the output.
Program 18: You have a stack named BooksStack that contains records of books. Each book
record is represented as a list containing book_title, author_name, and
publication_year. Write the following user-defined functions in Python to
perform the specified operations on the stack BooksStack:
(I) push_book(BooksStack, new_book): This function takes the stack BooksStack
and a new book record new_book as arguments and pushes the new book record
onto the stack.
(II) pop_book(BooksStack): This function pops the topmost book record from the
stack and returns it. If the stack is already empty, the function should display
"Underflow".
(III) peep(BookStack): This function displays the topmost element of the stack
without deleting it. If the stack is empty, the function should display 'None'.
Program 19: Write a Python function that displays all the words containing @cmail from a text
file "Emails.txt".
Program 20: Write a Python function that finds and displays all the words longer than 5
characters from a text file "Words.txt".
Program 21: Write a Python program to input an integer and display all its prime factors in
descending order, using a stack. For example, if the input number is 2100, the
output should be: 7 5 5 3 2 2 (because prime factorization of 2100 is
7x5x5x3x2x2) Hint: Smallest factor, other than 1, of any integer is guaranteed to
be prime.

Subject : Computer Science || Session : 2024-25 || Teacher : Sunil Nehra || Class : XII
Subject : Computer Science || Session : 2024-25 || Teacher : Sunil Nehra || Class : XII
SQL Queries
Program 22: Consider the table, MOVIEDETAILS given below :

Program 23: In a Database, there are two tables with the instances given below :

Write the statement to delete a column phone from the table students.

Subject : Computer Science || Session : 2024-25 || Teacher : Sunil Nehra || Class : XII
Subject : Computer Science || Session : 2024-25 || Teacher : Sunil Nehra || Class : XII
Program 24: Consider the following table EMPLOYEE and DEPARTMENT and answer (i)
and (ii) parts.

Program 25: Create a student table and insert data. Implement the following SQL commands
on the student table:
• ALTER table to add new attributes / modify data type / drop attribute
• UPDATE table to modify data
• ORDER By to display data in ascending / descending order
• DELETE to remove tuple(s)
• GROUP BY and find the min, max, sum, count and average

Subject : Computer Science || Session : 2024-25 || Teacher : Sunil Nehra || Class : XII
Subject : Computer Science || Session : 2024-25 || Teacher : Sunil Nehra || Class : XII
Python – SQL Connectivity
Note the following to establish connectivity between Python and MYSQL:
• Username is root
• Password is tiger
• Database is school
Write a Python database connectivity script that reads the record from the
table named student and displays only those records who have marks greater
than 75:
Program 26: RollNo – integer
Name – string
Class – integer
Marks – integer
Write a Python database connectivity script that deletes records from student
Program 27:
table that have name = “Sunil”.
Subodh Public School is managing student data in ‘Student’ table in ‘School’
Program 28: database. Write a Python code that connects to database school and retrieves
all records and displays total number of students.
Write a Python database connectivity script that insert records in student
Program 29:
table.

Subject : Computer Science || Session : 2024-25 || Teacher : Sunil Nehra || Class : XII

You might also like