0% found this document useful (0 votes)
65 views4 pages

Practical Assignment - Xii CS 2023-24

Uploaded by

Hansika Gidwani
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)
65 views4 pages

Practical Assignment - Xii CS 2023-24

Uploaded by

Hansika Gidwani
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/ 4

STANDARD XII

COMPUTER SCIENCE – PRACTICAL PROGRAMS


1. Write a python program that inputs a line of text (String) and perform the following using separate
functions.
(i) Count_Palindromes() - To count number of words which are palindromes in the string

(ii) Long_String( ) - To find the longest substring in the given string and returns.

Eg: String : “madam speaks malayalam and she refer many civic related topics”
Output : Number of palindromic words : 4
Longest Substring : malayalam

2. Write a program that inputs a list of ‘n’ integers perform the following using separate functions.
(i) Function FindSum(L) that finds and return the sum of all elements in the even index of the given list.
(ii)Function INDEX_LIST(L) 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]
3. Write a program that inputs a list of ‘ N’ integers and perform the following using separate functions
(i) To find the minimum and maximum elements in the list. Function name : Min_Max()
(Do not use min() of max() functions)
(ii)Function Rotate_right () that shifts the contents of each cell one place to the right,
except for the contents of the last cell, which should be moved into the cell with subscript 0.
Eg:Given a List with following elements: 5 -8 15 20 -6 10 -25 35 -50 19
The resultant List should look like: 19 5 -8 15 20 -6 10 -25 35 -50
4. Write a program to input a list of integers and pass to a function along with an empty dictionary.
Function should find the no. of odd numbers and no. of even numbers using a dictionary.
Eg: L=[5,6,8,9,13,15,17,20,23]
Output: Dictionary = {'Odd': 6, 'Even': 3}
Number of Odd Numbers : 6
Number of Even Numbers : 3

5. Write a program that inputs a line of text and store it into a text file “story1.txt”, and perform the
following using separate functions
(i) Countblanks( )- To read the content from a text file STORY.TXT, count and display the
number of blank spaces present in it.
(ii) Display() -To read the content and display the text in such a way that all upper case letters
are replaced with a symbol ‘@’.

Example: If the file TOPIC.TXT has the following content :


Education is The Most Powerful Weapon which You can use to Change the World
Output for Countblanks() : No. of blank spaces : 13
Output for Display():
@ducation is @he @ost @owerful @eapon which @ou can use to @hange the @orld

6. Write a program that inputs a paragraph of text and store it into a text file “notes1.txt” , and perform
the following using separate functions
(i) vowelwords(), that reads the file and display all the words that are starting with a lowercase vowel
(i.e. ‘a’, ‘e’, ‘i’, o’,‘u’).
(ii)Reverse() – To read from the file and display all the words in reverse order.
7. Write a program using separate functions to perform the following
(i) To open a file named “apple.txt” and store the following in separate lines
“Boxing rings are square
Actions speak louder than words
Neither apple nor pine are in pineapple
Overlook and oversee are opposites
An alarm goes off by going on.”
(ii)To display all the lines that start with letter ‘A’.
(iii)To read the content of the file and display all lines which are more than 5 words in it

8. Write a menu driven program to perform Employee related operations performed in a company
using a binary file “Employee.dat”. (Details of employees are represented in a LIST which
contains Empno, Empname, Department, Salary)
Write following functions
(i) Append an Employee’s details into the binary file
(ii) To search an employee for a given employee number
9. A binary file “Employee.dat” maintains the details of employees in a company
which has structure [Empno, Empname, Department, Salary]
(i) Write a user defined function AppendRecord() to append an Employee’s details into the binary file.
(ii)Write a user defined function AvgSalary()which accepts the department as parameter and find
the total salary of all employees in that department which are stored in the binary file “Employee.dat”.
10. Write a menu driven program to perform the operations of ‘n’ customers in a Bank using binary
file “BANK.dat”. Details of customers are to be stored in a dictionary which contains
AccNo : Store account number of a customer
AccName: Store name of account holder
Balance : Balance amount in Bank Eg:{‘AccNo’:101,’AccName’:’Arun’,’Balance’:500000}
Write following functions
(i) StoreData() – To append a Customer’s details into the binary file
(ii) SearchName(): A function to search for a customer based on a given customer name
11. A binary file items.dat containing records in the format {item_id:[item_name,amount]}
Write following functions:
i)Store_item(): To store the details of an item.
ii)Search(id): To display the name and amount of an item when id is entered.
iii)Display(): To display all the records whose amount is >100000
11. A CSV file student.csv maintains the details of students (Name, class, Year, Percent). Write
functions to perform the following using separate functions
(i) Append() -To input the details of ‘N’ students and store it into the csv file
(ii)To search and display the record of a given name of student from the csv file

12. Write a python program to perform the following in MySql using python Interface.
Using separate functions (Username : root, Password :1234Database name :School)

(i) CreateStudent() -To create a table Student with Rollno (integer), Name(varchar(20),
class char(5),Marks decimal(7,2), DOB (date) are various columns of the table.

(ii) AddRecord() -To insert the details of a student into the table Student
(22, ‘Kiran Raj’,’XII’, 88.5, ‘2004-12-20’)

13. Write a python program to perform the following in MySql using python Interface.
Using separate functions (Database name :School)
(i) To display all the records of all the students for the given class.(class is user input)
(ii) To update the table by editing the Marks for the given rollno. (rollno and marks are user input)

14. Write a menu driven program to perform the operations in a stack containing integer values
(Write separate functions for PUSH), POP() and DISPLAY()

15. Write a program that input a list of ‘n’ integers and using separate user defined
functions to perform the following operations based on this list.

● Traverse the content of the list and push the odd numbers into a stack.
● Pop and display the content of the stack.

16. Write a program that stores the month names and number of days in each month into a dictionary in
the form of key value pairs. Program, with separate user defined functions to perform the
following operations:

● Push the keys (month names) of the dictionary into a stack, where the corresponding value
(no of days ) is 30.
● Pop and display the content of the stack.

MySql
1. Create a database School21 and create the following table TEACHER and insert the given values and
execute the following SQL Query.
TEACHER
ID NAME DEPARTMENT HIREDATE CATEGORY GENDER SALARY
1 Tanya Hindi 2019-03-17 TGT F 25000
2 Saurabh Art 2020-02-12 PRT M 20000
3 Nandita English 2016-05-16 PGT F 30000
4 James English 2018-10-16 TGT M 25000
5 Manasi Hindi 2020-08-01 PRT F 22000
6 Diksha Math 2016-03-17 PRT F 21000
7 Subhash Math 2019-11-17 TGT M 24500
i. To list names, department and date of hiring of all teachers in ascending order of date of joining.
ii. To count the number of teachers in English department.
iii. Display the department and hire date of all the female teachers whose salary is more than 25000.
iv. Display the list of teachers whose name starts with ‘S’.
v. Display the total salary of female teachers from Hindi department.
vi. Display the maximum, average, minimum and total salary of teacher department wise.
vii. Display the sum of salary of teacher who have joined after ‘2018-01-01’.
viii. To increase the salary by 5% of all PGT teachers.
2. Create a database in your name. Make that database active and create the following table
HOSPITAL. Insert the given records and execute the following SQL Queries.
HOSPITAL
No Name Age Department Dateofadm Charges Gender
1 Pratik 62 Surgery 2011-10-12 300 M
2 Shubham 22 ENT 2011-10-15 250 M
3 Krinjal 32 Orthopedic 2011-10-16 200 F
4 Vipul 45 Surgery 2011-10-18 300 M
5 Supria 30 ENT 2011-10-22 250 F
6 Lakshit 10 Pediatric 2011-10-25 250 M

i. To list the names of female patients who are in ENT department.


ii. To list the details of patients in descending order of their Date of admission.
iii. To display patient’s name, Charges, Age for only female patients.
iv. To display the details patients whose department ends with the letter ‘c’.
v. To count the number of male patients in Surgery department
vi. To display total charges for male and female patients seperately.
vii. To display the different departments in the table HOSPITAL.

3. Create the following tables CUSTOMER and MOBILE and execute the
SQL commands for the statements

TABLE : CUSTOMER
ID Cname Validity Amount Connection
101 Preeti 365 2200 Jio
102 Sumit 60 980 Airtel
103 Aamir 180 1450 Jio
104 Mukul 30 400 BSNL
105 Ambani 380 2000 Jio
106 Rani 90 700 Airtel
107 Vijay 60 650 BSNL
TABLE : MOBILE
ID SetName Price
101 Samsung 250
102 Iphone 350
104 Oneplus 290
105 Iphone 400
107 Samsung 220
(i)To display Customer name and corresponding set name from the tables Customer and Mobile
(ii)To display the customer name, connection and the corresponding set name with price more than 250.
(iii) To display the details of all Iphone customers.
(iv)To count the number of customers with BSNL connection who uses Samsung phone.
(v) To display the Cname, Validity and SetName of all Jio customers.

You might also like