0% found this document useful (0 votes)
4 views48 pages

Xii-Cs-Board Practical List (Final)

The document outlines various programming tasks including string manipulation, file handling, and database operations. Each task includes an aim, a step-by-step procedure, and coding sections, covering topics such as string capitalization, palindrome checking, list element shifting, and SQL queries. The document concludes with results indicating that the expected outputs were obtained for each coding task.

Uploaded by

lakshatraravi
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)
4 views48 pages

Xii-Cs-Board Practical List (Final)

The document outlines various programming tasks including string manipulation, file handling, and database operations. Each task includes an aim, a step-by-step procedure, and coding sections, covering topics such as string capitalization, palindrome checking, list element shifting, and SQL queries. The document concludes with results indicating that the expected outputs were obtained for each coding task.

Uploaded by

lakshatraravi
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/ 48

```

1. STRING TRAVERSAL–NESTED IF

AIM: Get a sentence, capitalize each word first letter using if and display new
string
PROCEDURE:
Step 1: Start the process
Step2: Get a string as a sentence
Step 3: Using while loop traverse each letter of a string
Step 4: Check the character next to the space is capital or not. If not change
it as Uppercase and add to new string
Step 5: Display the new string
Step 6: Stop the process
CODING:

OUTPUT
```

2. STRING PALINDROME

AIM:
Read a string and check whether it is a palindrome or not
PROCEDURE:
Step 1: Start the process
Step 2: Get a string and find the mid character
Step 3: Repeat character in a string till mid position and check whether the
characters are equal from half to next half
Step 4: Display it ‘is a palindrome’ if it is equal or else display it ‘is not
palindrome’
Step 5: Stop the process
CODING:

OUTPUT

RESULT:

As per the coding given the expected output obtained


```

3. SHIFT ‘N‘ELEMENTS IN LIST

AIM:
From the list of elements shift first n elements to the last position.
PROCEDURE:
Step 1: Start the process
Step 2: Get number of items up to that read the list.
Step 3: Define a function Lshift(Arr,n) to exchange the no of elements
into the last position using for loop
Step 4: Display the list in function Step
5: Stop the process
CODING :

OUTPUT

RESULT:
As per the coding given the expected output obtained
```

4. CONVERT OCTAL TO OTHER NUMBERS.


AIM:
Get an octal number convert and display its other number system
PROCEDURE:
Step 1: Start the process
Step 2: Define a function octothers (n) to convert the number as string
and display it as a hexadecimal, binary, decimal using number
converting functions hex(),bin()
Step 3: In main part get one octal number and call the function to display
Step 4: Stop the process
CODING:

RESULT:

As per the coding given the expected output obtained OUTPUT


```

5. RANDOM MODULE FUNCTION


AIM:
To get number in dice using randint () function from random module.
PROCEDURE:
Step 1: Start the process
Step 2: Assigning min,max values are 1 and x .Input choice as ‘y‘
Step 3: Repeat the following till choice is ’y‘
Step 4: Assign val by import random and use randint(min,max)
Step 5: Display the val as dice numbers Step 6:
Stop the process
CODING:

OUTPUT

RESULT:
As per the coding given the expected output obtained
```

6. FIBONACCI SERIES
AIM:

To display given number terms of Fibonacci series also find its sum using
function
PROCEDURE:
Step 1: Start the process
Step 2: Input a number n
Step 3: Call the function fib () with argument n
Step 4: Assign a as 0 and b as 1 and display a,b
Step 5: Repeat the below process for n-2 number of times
Step 6: Add a and b display result, then b to a, a+b to b also s to b
Step 7: Return the sum value s to called place
Step 8: Display the sum value
Step 9: Stop the process
CODING:

OUTPUT
```

7. TRY….EXCEPT….ELSE…FINALLY EXCEPTION

AIM: To open existing file in python and check the type of exception will occur
on that file.
PROCEDURE:
Step 1: Start the process
Step 2: open a file name as ‘nonexistance_file.txt‘ and read the
content of file with read mode using read function
Step 3: To covert file as integer
Step 4: To find result=10/num and print the result
Step 5: Check if ‘FileNotFoundError‘ exception found print ‘file not
found‘
Step 6: Or else if ZeroDivisionError occurs, print ‘Error, cannot divide by
zero‘
Step 7: Or else if ‘Value Error‘occurs print‘invalid data
Step 8: Otherwise ‘unexpected error occurs ‘will be printed
Step 9: At last finally exception will be displayed
Step 10: Stop the process
CODING:

OUTPUT
```

8. COUNT CONSONANTS FROM TEXT FILE


AIM:
To read a file story.txt and count consonants in it
File content:
Python is an interpreted high level language, general purpose Computer
programming language.
Created by Guide Van Rossum and first released in 1991. Python‘s design
philosophy emphasizes code readability. Its Language constructs and
object oriented approach aim to help computer programmers write
clear, logical code.

PROCEDURE:
Step 1: Start the process
Step 2: In ‘D‘ drive save the given content as consonant.txt and open it
with file object ‘f‘ and read content using read () function.
Step 3: Store the element as vowels as elements of a list v
Step 4: Repeat a loop for check each character of string
as not a vowel in v
Step 5 : If true, increase the count of non-vowel character and display
result
Step 6: Stop the process

CODING:
```

OUTPUT:

RESULT:
As per the coding given the expected output is obtained
```

9. FIND TEXT,COUNT WORDS,LINES


AIM:
To open f file consonant.txt and count number of lines start with Letter p and
count the number of line in consonant.txt and number of words in file, then number
of time ‘computer’ in file

FILE CONTENT:
Python is an interpreted high level language, general purpose computer
programming language.
Created by Guide Van Rossum and first released in 1991. Python‘s design
philosophy emphasizes code readability. Its Language constructs and object
oriented approach aim to help computer programmers write clear, logical code.

PROCEDURE:

Step 1: Start the process


Step 2: In ‘D‘ drive save the given content as consonant.txt open it with file
object ‘f‘ and read file content using readlines () function as a list st
Step 3: Repeat a loop for all elements in list st, increase the line, count c1
and check the line start the letter ‘p‘ if so Increase count c
Step 4: Repeat a loop for and split each word of list element, to check the
word is ‘computer ‘or not and also increase word count s
Step 5: Display both counting as lines start with ‘p‘and total lines, total
words, and word of occurrences of computer‘
Step 6: Stop the process
```

CODING:

OUTPUT

RESULT:
As per the coding given the expected output is obtained
```

10. UPDATE DATA IN BINARY FILE

AIM: To open a file emp.dat and search the given empno to increase the salary.

PROCEDURE:
Step 1: Start the process
Step 2 : In ‘D‘ drive save the given dictionary to emp.dat and open in
with file object empfile and read file content using load()
from pickle module.
Step 3: Repeat a loop for all elements in list emp and check the
empno is find in
Step 4: If found, increase the salary by 2000, and dump the data into the
file using pickle module
Step 5: Display the modified employee details.
Step 6: Stop the process
CODING:
```

OUTPUT

RESULT:
As per the coding given the expected output is obtained

AIM:
```

11. SEARCH IN STUDENT RECORD

AIM:
To open a stu.dat file and store details of rollno, name, mark. Find the
occurrence of rollno and display the details.
PROCEDURE:
Step 1: Start the process
Step 2: Open a file stud.dat in write mode and declare a Dictionary
Step 3: Repeat until processing, get student details of rollno, name, and
mark and make it as a key: value pair in a dictionary
Step 4: Use pickle module to dump the dictionary
Step 5: Get some list of rollno and search the occurrences in a file and
display if found
Step 6: Stop the process
CODING:
```

OUTPUT

RESULT:
As per the coding given the expected output is obtained
```

12. CSV FILE-SPORT DETAILS


AIM:
Create a CSV file with tab separated delimiter of school sport winning
details and display the file
PROCEDURE:
Step 1 : Start the process
Step 2 : Open sports.csv, create writer object with delimiter of tab.
Step 3 : Make heading of sports, competitions and prizes won
Step 4: Repeat a loop for number of entries as you like
Step 5: Using reader object, display the prizes won details of the
sports file
Step 6: Stop the process

CODING:
```

OUTPUT

RESULT:
As per the coding given the expected output is obtained
```

13. CSV FILE - PERSONAL DATA

AIM:
Define add (), countr () functions to read and display the CSV file ‘emp.csv‘
 Add() : To accept and add a data of an employee to a csv file
‘emp.csv‘.Each record consists of a list with field elements as empid, name
and mobile to store employee id, employee name and employee salary
respectively
 Countr().To count the number of records present in the csv file named
‘emp.csv‘
PROCEDURE:
Step 1: Start the process
Step 2: Define a function add () to open a file ‘emp.csv‘and create writer
object
Step 3: Get employee details and store it as a single list and close the file.
Step 4: Define a function countr (), open a file ‘emp.csv‘and create reader
object

CODING
```

OUTPUT

RESULT:
As per the coding given the expected output is obtained
```

14. STACK OPERATION- I


AIM:

To get a list of elements and to perform stack process like Push,


pop, peek etc.
PROCEDURE:
Step 1: Start the process
Step 2: Define function separately to insert, delete and to display
stack
Step 3: Define a function isEmpty () to check the stack is empty or
not, if it is not an empty stack display the peek value of it.
Step 4: In main block display the list of choices, get the user Choice
and perform the stack process by calling the required
function.
Step 5: Repeat step 4 till user choose exit option from the list of
choice
Step 6 : Stop the process
CODING
```

OUTPUT
```

RESULT:
As per the coding given the expected output is obtained
```

15. STACK OPERATION-II


AIM:

To get a list of elements and to perform stack process like push, pop,
peek, etc.
PROCEDURE:
Step 1: Start the process
Step 2: Define function separately to insert, delete and to display
stack
Step 3: Define a function isEmpty() to check the stack is empty or not,
if it is not an empty stack display the peek value of it.
Step 4: In main block display the list of choices, get the user choice and
perform the stack process
Step 5: Repeat step 4 till user choose exit option from list of Choices.
Step 6: Stop the process.
CODING:
```

OUTPUT
```

RESULT:
As per the coding given the expected output is obtained
```

16.MYSQL-TABLE ‘EMP’
AIM:
To create a table ‘Emp‘ with the description given and perform SQL
Queries
TABLE DESCRIPTION:
Empno of type integer,empname of type varchar(20),dept of type
varchar(15),design of type varchar(15),basic of type integer and city of
type varchar(15);
PROCEDURE:
Step 1: Start the process
Step 2: Create a table ‘Emp‘with the description given above and insert
employee details
Step 3: Write SQL Queries for the given descriptions from table Emp
(i)To increase the basic by 5oo for those who worked in ‘MUMBAI‘
(ii)To display employee details whose name start with letter ‘k‘
(iii)To display empname and dept whose salary less than 30000;
(iv)Find highest salary of the employee whose design is ‘clerk‘
Step 4: Execute the given below queries and write the output.
(A)Select city, count(*) from emp group by city having count(*)>1;
(B)Select dept,sum(basic) as ‘total salary‘ from emp group by dept;
(C)Select * from emp where city=‘DELHI‘order by basic asc;
(D)Select * from emp group by city having basic >30000;
Step 5: Stop the process;
```

TABLE EMP

OUTPUT 1

(I)

(ii)

(iii)
```

OUTPUT 2:

(I)

(II)

(III)

RESULT: As per the given Queries in MYSQL, the expected output is


obtained.
```

17.MYSQL – AGGREGATE FUNCTIONS


AIM:
To create a table ‘emp1‘with the description given and perform SQL
Queries.

TABLE DESCRIPTION:
Empno of type integer, name of type varchar (20), job of type
varchar(2), MGR of type integer,hiredate of type date,sal of type
float,comm of type float,deptno of type integer.

PROCEDURE:
Step 1: Start the process
Step 2: Create a table ‘empl‘ with description given above and insert 14
employee details.
Step 3: Write SQL Queries for the given description from the table empl
(i)To count number of jobs in empl relation
(ii)To list distinct jobs in empl relation
(iii)To display the joining date of scalar most employee in empl
relation
(iv) To display total salary of all employees in empl relation
Step 4: Execute the given below queries and write the output.
(a)SELECT MAX(sal) ‘ MAXIMUM SALARY’ from emp1;
(b)SELECT AVG(sal(‘AVERAGE‘)) from empl;
(c)SELECT COUNT(*) ‘ TOTAL’ from emp1;
(d)SELECT ENAME, JOB, SAL, DEPTNO HAVING SAL>1500;
Step 5: Stop the process

(step 3) OUTPUT
```

i)

(i)

(ii)

(iii)

(iv)

(Step 4) OUTPUT

(a)
```

(b)

( c)

(d)

RESULT:
As per the given queries in MYSQL, the expected output is obtained.
```

18. MYSQL-TABLES ‘DEPT’,’WORKER’

AIM: To create table ‘DEPT‘and table ‘WORKER‘ with the description given and
perform SQL Queries

TABLE DESCRIPTION:
DEPT: DECODE as type varchar (5) and set as primary key, DEPARTMENT
as type varchar(15) and CITY of type varchar(10)
WORKER: WND of type integer, NAME of type varchar (20), DOJ of type date,
DOB of type date, GENDER of type varchar(15),DCODE of foreigh key
reference table DEPT.
PROCEDURE:
Step 1: Start the process
Step 2: Create a table ‘DEPT‘and insert 5 department details.
Step 3: Create a table ‘WORKER ‘and insert 7 worker details.
Step 4: Write SQL Queries for the given description
(i) To display wno,name from the table ‘WORKER‘ in
descending order of wno
(ii) To display the name of all female workers from the
‘WORKER‘
(iii) To display the wno and name of the workers from the table
‘WORKER‘ who are born in ‘1993—03—17‘ and ‘1994-07-10’
(iv) To count and display male worker who have joined After
‘1986-01-01‘
Step 5: Execute the given below queries and write the output.
(a)SELECT COUNT(*) ,DCODE FROM WORKER GROUP BY DECODE
HAVING COUNT(*)>1;
(b)SELECT DISTINCT DEPERTMENT FROM DEPT;
(c )SELECT NAME, DEPARTMENT, CITY FROM WORKER W,DEPT D
WHERE W.DCODE=D.DCODE AND WNO<1003
(d)SELECT MAX(DOJ) ,MIN(DOB) FROM WORKER
Step 6: Stop the process

RESULT: As per the given Queries in MYSQL, the expected output is obtained.
```

TABLE DEPT

TABLE WORKER

SQL STATEMENT
(I)

(II)
```

(IV)

(V)

(V)

(VI)

(VII)
```

19. MYSQL-TABLES-‘PASSENGER‘, ‘FLIGHT‘


AIM:
To create table ‘PASSENGER ‘and ‘FLIGHT ‘with the description given and
perform SQL Queries

TABLE DESCRIPTION:
PASSENGER: PNO as type integer, NAME of type varchar (10), GENDER
of type varchar (10), PNO of type varchar (5) and set as primary key.
FLIGHT: FNO of foreign key references table passenger, START of
type varchar (10), ENO of type varchar (10), FDATE of type date,
FARE of type integer

PROCEDURE:
Step1: Start the process
Step 2: Create a table ‘PASSENGER‘and insert 4 passenger details.
Step 3: Create a table ‘FLIGHT‘and insert 4 flight details.
Step 4: Write SQL Queries for the given descriptions
(i)To change the fare to 6000 of flight those FNO is F104
(ii)To display the total number of male and female passengers
(iii)To display the Name corresponding dare and f-date of all
Passenger who have flight to start from Delhi
(iv)To delete the records of flights which end at Mumbai
Step5: Execute the given below queries and write the output.
(a) SELECT ENO,MONTH(F DATE) ’MONTH’ FROM FLIGHT WHERE
FATE=4500;
(b) SELECT ENO FROM PASSENGER ORDER BY FNO DESC;
(c) SELECT NAME,GENDER FROM PASSENGER WHERE
PANO>=1003;
(d) SELECT SUM(FARE) FROM FLIGHT WHERE END IN
(‘Bangalore‘, ‘Mumbai‘);
Step 6: Stop the process
RESULT:
As per the given queries in MySQL, the expected output is obtained
```

TABLE PASSENGER:

TABLE FLIGHT

(I)

(II)

(III)
```

(IV)

(a)

(b)

(c)

(d)

RESULT:
As per the given queries in MySQL, the expected output is obtained.
```

20.MYSQL-TABLES-‘STUDENTS‘-‘SPORTS‘
AIM:
To create table ‘STUDENTS ‘and table ‘SPORTS ‘with the Description given
and perform SQL Queries. TABLE DESCRIPTION:
STUDENTS: ADMNO of type integer and set as primary key, NAME of
type varchar(10),CLASS of type varchar(5) ,SEC of type varchar(5),
RNO of type integer, ADDRESS of type varchar(10),PHONE of type integer;
SPORTS: ADMNO of foreign key references table STUDENTS, GNAME of type
varchar (2), COACH_NAME of type varchar(20),GRADE of type varchar(5)
PROCEDURE:
Step 1: Start the process
Step 2: Create a table ‘STUDENTS ‘and insert 4 students details.
Step 3: Create a table ‘SPORTS ‘and insert 4 sports details
Step 4: Write SQL Queries for the given descriptions.
(i)To display name and game of that student whose
address is available in ‘STDENTS‘?
(ii)To delete a column phone from the table ‘STUDENTS‘
(iii)To display name of the students who are studying in
class 12 and their corresponding coach name
(iv)To count the number of students who play volleyball
STEP 5: Execute the given below queries and write the output
(a)SELECCT NAME, CLASS FROM STUDENTS WHERE CLASS
LIKE IS ‘12%‘;
(b)SELECT ADMNO, GNAME FROM SPORTS WHERE GRADE=‘A‘
(c)SELECT ADMNO, NAME, ADDRESS FROM STUDENTS WHERE
ADDRESS IS NULL;
(d) SELECT COACHNAME FROM SPORTS WHERE ADMNO BETWEEN
1213 AND 1215
STEP 6 : Stop the process;
TABLE STUDENTS:

TABLE SPORTS:
```

(i)

(II)

(iii)

(iv)

STEP 5(OUTPUT)

(a)

(b)
```

(c )

(d)

RESULT:
As per the given queries in MySQL, the expected output is obtained.
```

21. INTERFACE-DISPLAY STUDENT RECORDS


AIM:
Create a table ‘STUDENTS ‘in the database ‘STUDENT ‘and fetch the values
from python code.
PROCEDURE:
Step 1: Start the process
Step 2: Use database STUDENT and create a table STUDENTS with
keys rollno, name, marks, grade, section project.
Step 3: Insert 6 students details.
Step 4: Import MYSQL connector and establish connection with
connect()
Step 5: Create a cursor and execute the command ‘SELECT * FROM
STUDENT‘
Step 6: Use fetchmany function to display first 3 students’ records.
Step 7: Stop the process
CODING:

OUTPUT
```

RESULT:
As per the coding given the expected output is obtained.
```

22. INTERFACE-ADD TUPLE TO STUDENT


AIM:
In python coding insert a record in MYSQL table ‘students’ also
change mark value by update command and display result.
PROCEDURE:
Step 1: Start the process
Step 2: Using table ‘students ‘ in MYSQL database ‘student‘
Step 3: import MySql connector and establish connection with
connect ()
Step 4: Create a cursor and execute the command ‘insert into student
(rollno, name,mark,grade,section) values (108,‘Aslam‘,
345,‘D‘,‘A‘)’
Step 5: Use commit () to ensure the data insert into table.
Step 6: Use execute () to update a mark value for the given name
Step 7: Use commit () to ensure the updation in the table.
Step 8: To view the result executes the Query ‘select *from students‘
Step 9: Stop the process
CODING:
```

OUTPUT

RESULT:
As per the coding given the expected output is obtained.
```

23. INTERFACE-DISPLAY RELATIONS AND DATABASE

AIM:
In python code from the list of MySQL database, use one database and list the
records from the selected table in that.
PROCEDURE:
Step 1: Start the process
Step 2: Import MYSQL. Connection and establish
connect with connect
Step 3: Execute ‘Show database ‘command to list all the database
available
Step 4: Execute ‘ Use student‘command to utilize tables.
Step 5: Execute ’Show tables‘command to list tables.
Step 6: Execute select statement to display the records in the table
Step 7: Stop the process
CODING:
```

OUTPUT

RESULT:
As per the coding given the expected output is obtained.
```

24. INTERFACE-DELETE A TUPLE


AIM:
From ‘sturecords‘ table delete a tuple
PROCEDURE:
Step 1: Start the process
Step 2: Create a table ‘sturecords‘in MySQL with attributes rollno, sname,
class, marks and insert 8 records
Step 3: Import MySQL connector and establish connection with connect ()
method
Step 4: Execute SELECT statement to display all the records.
Step 5: Delete one record from the displayed list and show rowcount for
deleted
Step 6: Execute the command select statement to display the balance
records
Step 7: Stop the process.

CODING:
```

OUTPUT:

RESULT:
As per the coding given the expected output is obtained.

You might also like