[go: up one dir, main page]

0% found this document useful (0 votes)
27 views30 pages

Pragyan Singh CS Practical File 2024-25

Uploaded by

noaddicive
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)
27 views30 pages

Pragyan Singh CS Practical File 2024-25

Uploaded by

noaddicive
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/ 30

Class XII-A: CS Practical file Page 1

S.No Date Name of the Exercise Page.No Signature


TABLE OF CONTENTS
Python Programs
1. Creating a menu driven program to perform arithmetic 3
operations. Page 2

2 Creating a menu driven program to find factorial and sum of list of 7


numbers using function.

3. Creating a python program to implement mathematical 10


functions.

4. Creating a python program to read a text file line by line and 12


display each word separated by '#'.

8. Creating python program to display short words from a text file 15

9. Creating a python program to create and search records in 17


binary file.

10. Creating a python program to create and search employee’s 21


record in csv file.

11. Creating a python program to implement stack operations 26


(Dictionary).
Python – SQL connectivity programs

12. Creating a python program to integrate MYSQL with Python 30


(Inserting records and displaying records)
13. Creating a python program to integrate MYSQL with Python 32
(Searching and displaying records)

SQL Queries
14 SQ L C O M M A N D S EXERCISE – 1 35
15. SQ L C O M M A N D S EXERCISE – 2 37
16. SQ L C O M M A N D S EXERCISE – 3 Class XII-A: 39
CS Practical file

17. SQ L C O M M A N D S EXERCISE – 4 41
18. SQ L C O M M A N D S EXERCISE – 5 43
DATE:
CREATING A M E N U DRIVEN PROGRAM T O PERFORM ARITHMETIC
OPERATIONS
AIM:

To write a menu driven Python Program to perform Arithmetic operations (+,-*,/)


based on the user’s choice.

S O U RC E CODE:

Result:
Thus, the above Python program has been executed and the output is verified
successfully.

Class XII-A: CS Practical file


Page 4

SAMPLE OUTPUT:

Python Program Executed Output:

***************************************************************************************

Class XII-A: CS Practical file


CREATING A MENU DRIVEN PROGRAM T O FIND FACTORIAL AND SUM OF LIST OF Page 5
NUMBERS USING FUNCTION.

AIM:
To write a menu driven Python Program to find Factorial and sum of list of numbers
using function.

S O U RC E CODE:

Result:
Thus, the above Python program has been executed and the output is verified
successfully.
Class XII-A: CS Practical file
Page 6

SAMPLE OUTPUT:
Python Executed Program Output:

************************************************************************************************

Class XII-A: CS Practical file


Page 7

CREATING A PYTHON PROGRAM TO IMPLEMENT MATHEMATICAL FUNCTIONS

AIM:

To write a Python program to implement python mathematical functions to find:

(i) To find Square of a Number.


(ii) To find Log of a Number(i.e. Log 10 )
(iii) To find Quad of a Number

S O U RC E CODE:

Result:
Thus, the above Python program has been executed and the output is verified
successfully.

SAMPLE OUTPUT:

Python Executed Program Output:

***************************************************************************

Class XII-A: CS Practical file


CREATING A PYTHON PROGRAM TO READ A TEXT FILE LINE BY LINE AND Page 8
DISPLAY EACH W O RD SEPARATED BY '#'

AIM:
To write a Python Program to Read a text file "Story.txt" line by line and display
each word separated by '#'.

S O U RC E CODE:

Result:

Thus, the above Python program has been executed and the output is verified
successfully.

SAMPLE OUTPUT:

Story.txt:

Class XII-A: CS Practical file


Page 9
CREATING PYTHON P RO G RA M T O DISPLAY SHORT WORDS FRO M A TEXT FILE

AIM:

To Write a method Disp() in Python, to read the lines from poem.txt and display those

words which are less than 5 characters.

Source Code:

Result:

Thus, the above Python program has been executed and the output is verified
successfully.
Sample Output:

Poem.txt:

Python Executed Program Output:

**********************************************************************************

Class XII-A: CS Practical file


Page 10
CREATING A PYTHON PROGRAM TO CREATE AND SEARCH RECORDS IN
BINARY FILE

AIM:
To write a Python Program to Create a binary file with roll number and name.
Search for a given roll number and display the name, if not found display appropriate
message.

S O U RC E CODE:

Result:
Thus, the above Python program has been executed and the output is verified
successfully.

Class XII-A: CS Practical file


SAMPLE OUPUT: Page 11

PYTHON PROGRAM EXECUTED OUTPUT:

*******************************************************************************************

Class XII-A: CS Practical file


Page 12

CREATING A PYTHON PROGRAM TO CREATE AND SEARCH EMPLOYEE’S RECORD


IN CSV FILE.

AIM:

To write a Python program Create a CSV file to store Empno, Name, Salary and search any Empno
and display Name, Salary and if not found display appropriate message.

S O U RC E CODE:

Result:
Thus, the above Python program has been executed and the output is verified
successfully.

Class XII-A: CS Practical file


Page 13

SAMPLE OUTPUT:

PYTHON PROGRAM EXECUTED OUTPUT:

******************************************************************************

Class XII-A: CS Practical file


Page 14
EX.NO: 15
DATE:

CREATING A PYTHON PROGRAM TO IMPLEMENT STACK OPERATIONS(Dictionary)

AIM:
To Write a program, with separate user-defined functions to perform the following
operations:
(i) To Create a function Push(Stk,D) Where Stack is an empty list and D is Dictionary of Items.
from this Dictionary Push the keys (name of the student) into a stack, where
the corresponding value (marks) is greater than 70.
(ii) To Create a Function Pop(Stk) , where Stk is a Stack implemented by a list of student
names. The function returns the items deleted from the stack.
(iii) To display the elements of the stack (after performing PUSH or POP).
Source Code:

Class XII-A: CS Practical file


Result: Page 15

Thus, the above Python program has been executed and the output is verified
successfully.

Sample Output:

*********************************************************************************

Class XII-A: CS Practical file


CREATING A PYTHON PROGRAM TO INTEGRATE MYSQL WITH PYTHON Page 16

(INSERTING RECORDS AND DISPLAYING RECORDS)

AIM:
To write a Python Program to integrate MYSQL with Python by inserting records to
Emp table and display the records.

S O U RCE CODE:

Result:
Thus, the above Python program has been executed and the output is verified
successfully.

Class XII-A: CS Practical file


SAMPLE OUTPUT: Page 17

Python Executed Program Output:

******************************************************************************************************************************************************************************

Class XII-A: CS Practical file


Page 18
CREATING A PYTHON PROGRAM T O INTEGRATE MYSQL WITH PYTHON

(SEARCHING AND DISPLAYING RECORDS)

AIM:
To write a Python Program to integrate MYSQL with Python to search an Employee using
EMPID and display the record if present in already existing table EMP, if not display the
appropriate message.

S O U RC E CODE:

Result:
Thus, the above Python program has been executed and the output is verified
successfully.

SAMPLE OUTPUT:

Python Executed Program Output:

Class XII-A: CS Practical file


Page 19

CREATING A PYTHON PROGRAM T O INTEGRATE MYSQL WITH PYTHON


(UPDATING RECORDS)

AIM:
To write a Python Program to integrate MYSQL with Python to search an Employee using
EMPID and update the Salary of an employee if present in already existing table
EMP, if not display the appropriate message.
S O U RC E CODE:

Result:
Thus, the above Python program has been executed and the output is verified
successfully.

Class XII-A: CS Practical file


SAMPLE OUTPUT: Page 20

Python Executed Program Output:

**************************************************************************************************************************************************

Class XII-A: CS Practical file

You might also like