Practical Programs 1
Practical Programs 1
PYTHON
PROGRAMS
Expt. No …………………… Page No……………….. Date……………………….
Program 1:
Write a program to check whether a number is palindrome or not.
Program Code:
Expt. No …………………… Page No……………….. Date……………………….
Output:
Expt. No …………………… Page No……………….. Date……………………….
Program 2:
Write a python program to print Fibonacci series upto n terms, also find sum of series.
Program Code:
Expt. No …………………… Page No……………….. Date……………………….
Output:
Expt. No …………………… Page No……………….. Date……………………….
Program 3:
Write a program to generate values from 1 to 10 and then remove all the odd
numbers from the list.
Program Code:
Expt. No …………………… Page No……………….. Date……………………….
Output:
Expt. No …………………… Page No……………….. Date……………………….
Program 4:
Write a program to find sum of all elements of a list using recursion
Program Code:
Expt. No …………………… Page No……………….. Date……………………….
Output:
Expt. No …………………… Page No……………….. Date……………………….
Program 5:
Write a program to count frequency of word in a given string/sentence.
Program Code:
Expt. No …………………… Page No……………….. Date……………………….
Output:
Expt. No …………………… Page No……………….. Date……………………….
Program 6:
Write a random number generator that generates random numbers between
1 and 6 (simulates a dice)
Program Code:
Expt. No …………………… Page No……………….. Date……………………….
Output:
Expt. No …………………… Page No……………….. Date……………………….
Program 7:
Write a program to count number of words in a text file.
Program Code:
Expt. No …………………… Page No……………….. Date……………………….
Text File:
Output:
Expt. No …………………… Page No……………….. Date……………………….
Program 8:
Program to read a text file line by line and display each word separated by a ‘#’.
Program Code:
Expt. No …………………… Page No……………….. Date……………………….
Text File:
Output:
Expt. No …………………… Page No……………….. Date……………………….
Program 9:
Program to read a text file and display the number of vowels /consonants/ uppercase/
lowercase characters in the file.
Program Code:
Expt. No …………………… Page No……………….. Date……………………….
Text File:
Output:
Expt. No …………………… Page No……………….. Date……………………….
Program 10:
Program to remove all the lines that contain the character ‘a’ in a file and write it to
another file.
Program Code:
Expt. No …………………… Page No……………….. Date……………………….
Text File:
Output:
Expt. No …………………… Page No……………….. Date……………………….
Program 11:
Create a binary file with roll number, name, marks and marks. Search for a given roll
number and display the details of the students, if not found display appropriate
message.
Program Code:
Expt. No …………………… Page No……………….. Date……………………….
Expt. No …………………… Page No……………….. Date……………………….
Output:
Expt. No …………………… Page No……………….. Date……………………….
Expt. No …………………… Page No……………….. Date……………………….
Program 12:
Create a binary file with roll number, name and marks. Input a roll number and update
the marks.
Program Code:
Expt. No …………………… Page No……………….. Date……………………….
Expt. No …………………… Page No……………….. Date……………………….
Output:
Expt. No …………………… Page No……………….. Date……………………….
Expt. No …………………… Page No……………….. Date……………………….
Program 13:
Write a menu-based python program to implement a stack using list
(Push, Pop, Display and Exit).
Program Code:
Expt. No …………………… Page No……………….. Date……………………….
Output:
Expt. No …………………… Page No……………….. Date……………………….
Expt. No …………………… Page No……………….. Date……………………….
Program 14:
Create a CSV file (data.csv) by entering roll number, name and marks. Then read and
search the marks for given roll number.
Program Code:
Expt. No …………………… Page No……………….. Date……………………….
Expt. No …………………… Page No……………….. Date……………………….
Output:
Expt. No …………………… Page No……………….. Date……………………….
Expt. No …………………… Page No……………….. Date……………………….
Program 15:
Create a CSV file (detail.csv) by entering roll number, name and marks. Then read from
the csv file (details.csv) of those student’s details who scored more than 75 marks.
Program Code:
Expt. No …………………… Page No……………….. Date……………………….
Expt. No …………………… Page No……………….. Date……………………….
Output:
Expt. No …………………… Page No……………….. Date……………………….
Program 16:
Create a CSV file by entering user-id and password, read and search the password for
given user-id.
Program Code:
Expt. No …………………… Page No……………….. Date……………………….
Output:
Expt. No …………………… Page No……………….. Date……………………….
SQL
COMMANDS
Expt. No …………………… Page No……………….. Date……………………….
2. Use Database:
Command:
mysql> use class12cs;
Output:
3. Create Table:
Command:
mysql> create table Student
-> (Rno int Primary Key,
-> Name varchar(10) NOT NULL,
-> Gender varchar(8),
-> Marks int,
-> Scode varchar(5)
-> );
Output:
Expt. No …………………… Page No……………….. Date……………………….
5. Insert Command:
Command:
mysql>insert into Student value(1,'Neha','Female',100,'S101');
mysql> insert into Student value(2,'Nisha','Female',100,'S101');
mysql> insert into Student value(3,'Pooja','Female',75,'S102');
mysql> insert into Student value(4,'Pankaj','male',42,'S103');
mysql> insert into Student value(5,'Priyanka','Female',72,'S102');
mysql> insert into Student value(6,'Soniya','Female',85,'S101');
mysql> insert into Student value(7,'Soumya','Female',15,'S103');
mysql> insert into Student value(8,'Uttkarsh','male',99,'S101');
mysql> insert into Student value(9,'Ajay','male',98,'S101');
mysql> insert into Student value(10,'Muskan','Female',100,'S102');
mysql> insert into Student value(11,'Satish','male',50,'S103');
Expt. No …………………… Page No……………….. Date……………………….
Output:
6. Select Command:
Command:
mysql> select * from Student;
Expt. No …………………… Page No……………….. Date……………………….
Output:
After Modification:
2nd Command:
mysql> update Student set Address= 'Sector 17' where Scode='S101';
Output:
2nd Command:
mysql> select Name, Marks from Student order by Marks desc;
Output:
After Deletion:
1st Command:
mysql> delete from Student where Rno=6;
Output:
2nd Command:
mysql>delete from Student where Marks<20;
Output:
Expt. No …………………… Page No……………….. Date……………………….
13.Group By:
1st Command:
mysql>select Gender, Count(*) from Student group by Gender;
Output:
2nd Command:
mysql>select Scode, count(*) from Student group by Scode;
Output:
3rd Command:
mysql>select Scode, count(*) from Student group by Scode having
count(*)>2;
Output:
Expt. No …………………… Page No……………….. Date……………………….
1. Create Table
SQL Code:
mysql> create table Employee (
-> Empid Integer Primary Key,
-> Name varchar (20) Not Null,
-> Gender varchar (1),
-> Age Integer (2),
-> Department varchar (20) NOT NULL,
-> Salary Integer,
-> Place varchar (20),
-> DOJ date
-> );
Expt. No …………………… Page No……………….. Date……………………….
Output:
3. Select Command:
Command:
PYTHON – SQL
CONNECTIVITY
PROGRAMS
Expt. No …………………… Page No……………….. Date……………………….
Program 1:
Program to connect with database and store record of employee and display records
Program Code:
Expt. No …………………… Page No……………….. Date……………………….
Output:
Expt. No …………………… Page No……………….. Date……………………….
Program 2:
Program to connect with database and search employee number in table employee
and display record, if empno not found display appropriate message.
Program Code:
Expt. No …………………… Page No……………….. Date……………………….
Output:
Expt. No …………………… Page No……………….. Date……………………….
Program 3:
Program to connect with database and update the employee record of entered empno.
Program Code:
Expt. No …………………… Page No……………….. Date……………………….
Expt. No …………………… Page No……………….. Date……………………….
Output:
Expt. No …………………… Page No……………….. Date……………………….
Program 4:
Program to connect with database and delete the record of entered employee number.
Program Code:
Expt. No …………………… Page No……………….. Date……………………….
Output: