Xii-Cs-Board Practical List (Final)
Xii-Cs-Board Practical List (Final)
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:
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
```
RESULT:
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
```
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
```
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:
CODING:
OUTPUT
RESULT:
As per the coding given the expected output is obtained
```
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:
```
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
```
CODING:
```
OUTPUT
RESULT:
As per the coding given the expected output is obtained
```
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
```
OUTPUT
```
RESULT:
As per the coding given the expected output is obtained
```
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)
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.
```
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)
```
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.
```
OUTPUT
```
RESULT:
As per the coding given the expected output is obtained.
```
OUTPUT
RESULT:
As per the coding given the expected output is obtained.
```
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.
```
CODING:
```
OUTPUT:
RESULT:
As per the coding given the expected output is obtained.