cs practical file
cs practical file
Computer science
Practical file
(2024-25)
Amit Sethi
C.S. teacher
PYTHON PROGRAMMES
Output:
Enter a character: a
97
2) Write a program to read a text file line by line and display each word separated by '#'.
Text in file:
hello#how#are#you?#python#is#case-sensitive#language.#
Output:
Output:
Number is Palindrome
5) Write a program to search a record using its roll number and display the name of student. If record not
found then display appropriate message.
import pickle
roll = input('Enter roll number that you want to search in binary file :')
Output:
Enter roll number that you want to search in binary file :1202
6) Write a program to generate random numbers between 1 to 6 and check whether a user won a lottery or
not.
Output:
7) Write a program to count the number of times the occurrence of 'is' word in a text file.
Output:
8) Write a program to write those lines which have the character 'p' from one text file to another text file.
Output:
9) Create a binary file with name and roll number of student and display the data by reading the file.
Output:
10) Write a program to update the name of student by using its roll number in a binary file.
Output:
Enter roll number whose name you want to update in binary file :1202
Updated
11) Program to store student’s details like admission number, roll number, name and percentage in a dictionary
and display information on the basis of admission number.
Output:
12) Program to read the content of file and display the total number of consonants, uppercase, vowels and
lower case characters.
Output:
Output:
Record Deleted
Output:
The sorted list is : [8, 13, 19, 34, 65, 67, 74, 89]
MYSQL QUERIES
1) To write SQL-queries for the following questions based on the given table:
(f) Write a Query to insert all the rows of above table into Info table.
2) To write SQL-queries for the following questions based on the given two table :
3) Queries for Aggregate functions- SUM( ), AVG( ), MIN( ), MAX( ), COUNT( )
d. Find the total salary of those employees who work in Guwahati city.
5) Write SQL queries using SELECT, FROM, WHERE clause based on EMPLOYEE table.
2. Display the name and department of those employees who work in surat and salary is greater than 25000.
Solution:- SELECT Ename, Dept FROM EMPLOYEE WHERE city=’surat’ and salary > 25000;
6) Queries using DISTINCT, BETWEEN, IN, LIKE, IS NULL, ORDER BY, GROUP BY, HAVING
B. Find the name and salary of those employees whose salary is between 35000 and 40000.
SOLUTION: SELECT Ename, salary FROM EMPLOYEE WHERE salary BETWEEN 35000 and 40000;
C. Find the name of those employees who live in guwahati, surat or jaipur city.
1) Program to connect with database and store record of employee and display records
Output:
2) Program to connect with database and search employee number in table employee and display record, if
empno not found display appropriate message.
Output:
3) Perform all the operations (Insert, Update, Delete, Display) with reference to table ‘student’ throughMySQL-
Python connectivity
import mysql.connector as ms
Output:
4) Write a Menu Based Python databaseconnectivity script that performs thefollowing operations on the
tablenamed PRODUCT in SHOP Database.Observe the data given and setsuitable primary key for the table
and appropriate datatypes for the fields.
Output: