0% found this document useful (0 votes)
10 views31 pages

12thpracticals CS

The document outlines various Python programs and SQL queries for file handling, data processing, and database management. It includes tasks such as reading files, counting characters, creating and modifying binary files, generating random numbers, and performing CRUD operations on a database. Additionally, it provides SQL queries for creating and manipulating tables, as well as updating and deleting records.

Uploaded by

rushil1212007
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)
10 views31 pages

12thpracticals CS

The document outlines various Python programs and SQL queries for file handling, data processing, and database management. It includes tasks such as reading files, counting characters, creating and modifying binary files, generating random numbers, and performing CRUD operations on a database. Additionally, it provides SQL queries for creating and manipulating tables, as well as updating and deleting records.

Uploaded by

rushil1212007
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/ 31

Program 1:

Read a text file line by line and display each word separated by a #.

Output :
welcome#to#python#class#welcome#to#CBSE#class#12#program#1#School#programming
Program 2 :

Read a text file and display the number of


vowels/consonants/uppercase/lowercase characters in the file
Output :
Digits: 3
Vowels: 19
Consonants: 43
Upper Case: 5
Lower Case: 57
other than letters and digit: 0
Program 3:
Remove all the lines that contain the character 'a' in a file and write it
to another file

Output : A new file myfile3_new.txt is created that has content

welcome to
world of
python
Program 4:
Create a binary file with name and roll number. Search for a given roll
number and display the name, if not found display appropriate
message.
Output:
Program 5:
Create a binary file with roll number, name and marks. Input a roll
number and update the marks.
Output :
Program 6:
Write a random number generator that generates random numbers
between 1 and 6 (simulates a dice).
Program 7 :
Write a Python program to implement a stack using list.
8. Create a CSV file by entering user-id and password, read and
search the password for given user-id
Output :

A csv file program8.csv is created in the same folder as the Python


file.

Its content will be :


User Id,password
ajay12,abcd123
bijoy@12,xyz#321
9. Program to connect with database and store record of employee
and display records
Output:
Program 10:
Program to connect with database and search employee number in
table employee and display record, if emp number not found display
appropriate message.
Output :

Note : The content of EMPL table is below


Program 11: Perform all the operations (Insert, Update, Delete,
Display) with reference to table a ‘student’ table
Output : Initially the table is empty.
Program 12:
To write SQL queries to create a table like below

a. Write a query to create Database sql_lab

b. Write a query to open Database sql_lab

c. Write a query to create table student in the database


d. Write a Query to insert all the rows of data into above table

e. Write a query to read the data


Program 13:
To write SQL- Queries for the following Questions based on the given
table:

a. Write a query to DELETE row corresponding to “ENR107”

After deleting
b. Write a query to update Marks in maths to 49 for ENR103

After updation:

c. Write a query to view the data in descending order of physics


marks
d. Write a query to group the data based on section and find
Minimum, Maximum and Average for physics for each section

e. Add a new field “phone” in the student table

f. Add phone number for few students


After adding phone numbers

g. Modify datatype of name from VARCHAR (20) to VARCHAR (10)


Before modifying

ALTER the datatype for name to VARCHAR (10)


After modification

You might also like