0% found this document useful (0 votes)
56 views6 pages

Class 12 Practical With Answers

The document outlines practical exam tasks for Class 12 Computer Science, focusing on Python programming and SQL queries. It includes instructions for creating programs to check prime numbers, analyze text files, manage binary and CSV files, and implement a stack. Additionally, it provides SQL queries for managing a 'Student' table, including creating, inserting, updating, and querying student data based on various conditions.
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)
56 views6 pages

Class 12 Practical With Answers

The document outlines practical exam tasks for Class 12 Computer Science, focusing on Python programming and SQL queries. It includes instructions for creating programs to check prime numbers, analyze text files, manage binary and CSV files, and implement a stack. Additionally, it provides SQL queries for managing a 'Student' table, including creating, inserting, updating, and querying student data based on various conditions.
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

CLASS 12 : COMPUTER SCIENCE BOARD PRACTICAL EXAM 2025-26

PYTHON PROGRAMS
1. Write a program using user defined function CheckPrime(N) that takes a number N as
parameter and display the prime numbers from 2 to N

2. Write a program using user defined function to read a text file and display the number of
vowels , consonants, uppercase and lowercase characters in it.
3. Write a program using user defined function to create a binary file with rollno and name.
Search for a given rollno and display the name, if not found display appropriate message.

4. Write a program using user defined function to create a CSV file by entering userid and
password. Display the password for given userid .
5. Write a Python program to implement a stack using list.

OR
DATABASE MANAGEMENT
1) Write the sql queries for the following questions:
i) Create the following table Student:

ii) Insert the following information to the table student: 111, ‘Anu Jain’ , 12, ‘A’, 2500
iii) Display the details of the students in the ascending order of fees
iv) Display the number of students in each class
v) Increase fees value by 500
ANSWER
i) CREATE TABLE Student ( Adno INT(3) Primary key, Name Varchar(20) NOT NULL, Class INT(2),
Section Char(1), Fees Float(10,2) );
ii) INSERT INTO Student VALUES (111, ‘Anu Jain’, 12, ‘A’, 2500)
iii) SELECT * FROM Student ORDER BY Fees;
iv) SELECT Class, COUNT(*) FROM Student GROUP BY Class;
v) UPDATE Student SET Fees = Fees + 500 ;

2) Write the sql queries for the following questions:


Table : Student

i) Display name of 10th class student information.


ii) Display students’ name , who are paying above or equal to 3000 fees.
iii) Display the names that start with letter ‘A’.
iv) Display students’ information, who are paying fees between 2500 and 3500
iv)Display sum of fees for each class.
ANSWER
i) SELECT Name FROM Student WHERE Class = 10;

ii) SELECT Name FROM Student WHERE Fees >= 3000;

iii) SELECT Name FROM Student WHERE Name LIKE “A%” ;

iv) SELECT * FROM Student WHERE Fees BETWEEN 2500 AND 3500 ;

v) SELECT Class ,SUM(Fees) FROM Student GROUP BY Class;


3) Write the sql queries for the following questions:
Table : Student

i) Display students’ information , who are paying fees between 2500 and 3500
ii) Remove adno 444 information.
iii) Add new column totalfees with number(10,2)
iv) Increase the fees value by 100 for adno 222
v) Display lowest and highest fees.

ANSWER
i) SELECT * FROM Student WHERE Fees BETWEEN 2500 AND 3500;
ii) DELETE FROM Student WHERE Adno = 444;
iii) ALTER TABLE Student ADD TotalFees Float(10,2);
iv) UPDATE Student SET Fees = Fees + 100 WHERE Adno =222;

v) SELECT MIN(Fees) , MAX(Fees) FROM Student;

4) Write the sql queries for the following questions:


Table : Student

i) Display students’ information , who are in section A and B.


ii) Display information of students in class 11B.
iii) Display the details of the students in descending order of fees.
iv) Display the sum and average of fees.
v) Change the fee datatype as number (12,2)

ANSWER
i) SELECT * FROM Student WHERE Section =’A’ OR Section = ‘B’;
ii) SELECT * FROM Student WHERE Class = 11 AND Section = ‘B’;
iii) SELECT * FROM student ORDER BY Fees DESC;
iv) SELECT SUM(Fees) , AVG(Fees) FROM Student;
v) ALTER TABLE Student MODIFY Fees Float(12,2);
5) Write the sql queries for the following questions:
Table : Student

i) Display 11th and 12th class students’ information.


ii) Display sum of fees for each class.
iii) Display different classes from student table.
iv) Increase the fees value by 100 for adno 222.
v) Add new column totalfees with number(10,2)
ANSWER
i) SELECT * FROM Student WHERE Class = 11 OR Class = 12;
ii) SELECT Class, SUM(Fees) FROM Student GROUP BY Class;
iii) SELECT DISTINCT Class FROM Student;
iv) UPDATE Student SET Fees = Fees + 100 WHERE Adno = 222;
v) ALTER TABLE Student ADD Totalfees Float(10,2);

6. Write the sql queries for the following questions:

ANSWER
i) SELECT Iname, Price, Bname FROM Item I , Brand B WHERE [Link] = [Link] AND
Price BETWEEN 25000 AND 30000;

ii) SELECT Icode , Price , Bname FROM Item I , Brand B WHERE [Link] = [Link] AND
Iname = “Television”;

iii) UPDATE Item SET Price = Price + Price *0.1 ;

Common questions

Powered by AI

To design a function in Python to read a text file and count the vowels, consonants, uppercase, and lowercase characters, you can define a function that opens the file for reading, iterates over each character, and uses Python string methods like isupper(), islower(), and isalpha(). Initialize counters for each category and increment them based on the conditions when reading each character from the file.

To write a Python program to display prime numbers from 2 to a given number N using a user-defined function, you can define a function CheckPrime(N) that iterates through each number from 2 to N. For each number, check if it is prime by testing divisibility from 2 up to the square root of the number. If a number is only divisible by 1 and itself, it is a prime number.

To manipulate a 'Student' table in SQL by adding a new column and modifying the fees for a specific student, you can use the following queries: To add a new column, use `ALTER TABLE Student ADD TotalFees Float(10,2);`. To modify the fees for a student with a specific adno (e.g., 222), use `UPDATE Student SET Fees = Fees + 100 WHERE Adno = 222;`.

To update a binary file with student records in Python, open the file in read+write binary mode. Use pickle module to read records, identify the target record through a search (e.g., based on roll number), update the relevant fields, then write back the changes. Ensure file pointers are correctly managed for read/write operations..

To display student details sorted in descending order by fees, use `SELECT * FROM student ORDER BY Fees DESC;`. To compute the sum and average of student fees, use `SELECT SUM(Fees), AVG(Fees) FROM Student;`.

To delete a student's record by admission number, use `DELETE FROM Student WHERE Adno = 444;`. This operation removes all data associated with that admission number, which could affect database integrity by removing links to related data, potentially leading to data anomalies unless integrity constraints or cascading deletes are managed properly..

To list all unique classes in a student table, use `SELECT DISTINCT Class FROM Student;`. This information is useful for generating reports, allocating resources, or identifying specific class cohorts for administrative tasks..

To modify a SQL table structure to change the data type of a column, use an ALTER TABLE statement. For instance, to adjust the data type of a fees column in a student table, execute `ALTER TABLE Student MODIFY Fees Float(12,2);`. This change might be needed to increase precision for financial data.

To configure a stack in Python using a list, implement methods to push items to the end of the list and pop items from the end. This mimics the last-in, first-out (LIFO) property of stacks. Unlike traditional stacks that might use linked lists for dynamic memory usage, Python's list-based stack solutions are simpler and leverage built-in list methods like append() and pop().

To securely create a CSV file in Python to store user IDs and passwords, use the csv module to write the rows. Ensure passwords are hashed for security. Implement a function to look up a user ID and verify the password hash against stored values, avoiding storing plaintext passwords for security compliance..

You might also like