0% found this document useful (0 votes)
255 views22 pages

CS Term 1 Practical Prog

The document contains 15 programming exercises to create Python programs that perform various tasks like arithmetic operations, Fibonacci series, random number generation, string processing, file handling and more. Each exercise lists the aim, source code, result and sample output of executing the program. The programs cover concepts like functions, mathematical operations, reading/writing to text and binary files, and searching/modifying records in CSV files.

Uploaded by

SEL
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)
255 views22 pages

CS Term 1 Practical Prog

The document contains 15 programming exercises to create Python programs that perform various tasks like arithmetic operations, Fibonacci series, random number generation, string processing, file handling and more. Each exercise lists the aim, source code, result and sample output of executing the program. The programs cover concepts like functions, mathematical operations, reading/writing to text and binary files, and searching/modifying records in CSV files.

Uploaded by

SEL
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/ 22

EX.

NO: 1
DATE:

CREATING A MENU DRIVEN PROGRAM TO PERFORM ARITHMETIC


OPERATIONS

AIM:

To write a menu driven Python Program to perform Arithmetic operations (+,-*, /)based
on the user’s choice.

SOURCE CODE:

RESULT:
Thus, the above Python program is executed successfully and the output is verified.
SAMPLE OUTPUT:

Python Program Executed Output:


Run – 1:

RUN- 2

***************************************************************************************
EX.NO: 2
DATE:

CREATING A PYTHON PROGRAM TO DISPLAY FIBONACCI SERIES

AIM:
To write a Python Program to display Fibonacci Series up to ‘n’ numbers.

SOURCE CODE:

RESULT:
Thus, the above Python program is executed successfully and the output is verified.
SAMPLE OUTPUT:

Python Executed Program Output:

RUN -1:

RUN -2 :

*****************************************************************************************
EX.NO: 3
DATE:

CREATING A PYTHON PROGRAM TO GENERATE RANDOM NUMBER


BETWEEN 1 TO 6

AIM:

To write a Python program to generate random number between 1 to 6 to simulate


the dice.

SOURCE CODE:

RESULT:
Thus, the above Python program is executed successfully and the output is verified.

SAMPLE OUTPUT:
Python Executed Output Program:

**************************************************************************************
EX.NO: 4

DATE:

CREATING A PYTHON PROGRAM TO COUNT NUMBER OF VOWELS PRESENT


IN A STRING

AIM:

To write a Python program to count vowels in an inputted string.

SOURCE CODE:

RESULT:
Thus, the above Python program is executed successfully and the output is verified.

Sample Output:

RUN – 1:

Run – 2:

**************************************************************************************
EX.NO: 5
DATE:

CREATING A PYTHON PROGRAM TO DISPLAY THE SUM OF EVEN NUMBERS


OF A LIST

AIM:

To write a Python program to display the sum of even numbers of a list.

SOURCE CODE:

RESULT:
Thus, the above Python program is executed successfully and the output is verified.

SAMPLE OUTPUT:

**************************************************************************************
EX.NO: 6

DATE:

CREATING A PYTHON PROGRAM TO FIND FACTORIAL OF A NUMBER


USING FUNCTION

AIM:
To write a Python program to find a Factorial of a number inputted by the user.

SOURCE CODE:

RESULT:

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

SAMPLE OUTPUT:

RUN – 1:

RUN – 2:

**************************************************************************************
EX.NO: 7

DATE:

CREATING A MENU DRIVEN PROGRAM TO FIND AREA OF CIRCLE, RECTANGLE AND


TRIANGLE

AIM:
To write a menu driven Python Program to find Area of Circle, Rectangle and Triangle.
Using function.

SOURCE CODE:

RESULT:
Thus, the above Python program is executed successfully and the output is verified.
SAMPLE OUTPUT:

RUN – 1:

RUN – 2:

**************************************************************************************
EX.NO: 8

DATE:

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. Log10)
(iii) To find Quad of a Number

SOURCE CODE:

RESULT:
Thus, the above Python program is executed successfully and the output is verified.

SAMPLE OUTPUT:

Python Executed Program Output:

**************************************************************************************
EX.NO: 9
DATE:

CREATING A PYTHON PROGRAM TO READ A TEXT FILE AND DISPLAY THE


NUMBER OF VOWELS/CONSONANTS/LOWER CASE/ UPPER CASE CHARACTERS.

AIM:

To write a Python Program to read a text file "Story.txt" and displays the number of
Vowels/ Consonants/ Lowercase / Uppercase/characters in the file.

SOURCE CODE:

RESULT:
Thus, the above Python program is executed successfully and the output is verified.
SAMPLE OUTPUT:
Story.txt:

*******************************************************************************
EX.NO: 10
DATE:

CREATING PYTHON PROGRAM TO FIND FREQUENCY OF "He" or "She" WORDS PRESENT IN A


TEXT FILE

AIM:

To write a Python Program to count the occurrences of the words "He" or "She"
from the text file “Info.txt”

SOURCE CODE:

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

SAMPLE OUTPUT:
Info.txt:

Python Program Executed Output:


EX.NO: 11

DATE:

CREATING A PYTHON PROGRAM TO READ A TEXT FILE LINE BY LINE AND


DISPLAY EACH WORD SEPARATED BY '#'

AIM:

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

SOURCE CODE:

Result:

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

SAMPLE OUTPUT:

Story.txt:

***************************************************************************
EX.NO:12

DATE:

CREATING A PYTHON PROGRAM TO COPY PARTICULAR LINES OF A TEXT FILE


INTO AN ANOTHER TEXT FILE

AIM:

To write a python program to read lines from a text file "Sample.txt" and copy those lines
into another file which are starting with an alphabet 'a' or 'A'.

SOURCE CODE:

Result:
Thus the above Python program is executed successfully and the output is verified.
SAMPLE OUTPUT:

Python Executed Program output:


Sample.txt:

Python Executed Program Output:

New.txt:

*****************************************************************************************
EX.NO: 13
DATE:

CREATING A PYTHON PROGRAM TO CREATE AND DISPLAY ALL RECORDS IN


BINARY FILE

AIM:

To write a Python Program to Create a binary file with Empno, Name, Salary
then read and display their details on screen.

SOURCE CODE:

Result:
Thus the above Python program is executed successfully and the output is verified.
SAMPLE OUTPUT:
EX.NO: 14
DATE:

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.

SOURCE CODE:

Result:
Thus , the above Python program is executed successfully and the output is verified.
SAMPLE OUPUT:

PYTHON PROGRAM EXECUTED OUTPUT:

************************************************************************************
EX.NO: 15
DATE:

CREATING A PYTHON PROGRAM TO CREATE AND SEARCH STUDENTS’ RECORD IN


CSV FILE.

AIM:

To write a Python program Create a CSV file to store Rollno, Name, Age and search any
Rollno and display Name, Age and if not found display appropriate message.
SOURCE CODE:

Result:
Thus, the above Python program is executed successfully and the output is verified.
SAMPLE OUTPUT:

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

You might also like