0% found this document useful (0 votes)
12 views

CS Report File Part 1

B

Uploaded by

RM Prajan
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)
12 views

CS Report File Part 1

B

Uploaded by

RM Prajan
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/ 40

VELAMMAL VIDHYASHRAM

(CBSE)
Guduvanchery

COMPUTER SCIENCE PRACTICAL (083)


Report File (2024 – 25)

Name __________________________

Class & Sec __________________________

Register Number __________________________


CONTENTS
EX. PAGE TEACHER’S
DATE NAME OF THE PROGRAM
NO. NO. SIGNATURE
PYTHON
EX: NO: 1 ARITHMETIC CALCULATOR
DATE:

QUESTION:
Write a Python program to implement Arithmetic Calculator using if…elif…else statement.

AIM:
To write a Python program to implement Arithmetic Calculator using if…elif…else statement.

ALGORITHM:
Step 1: Start.
Step 2: Get two numbers as input, say num1 and num2.
Step 3: Initialize a variable, result to 0.
Step 4: Get the desired arithmetic operator as input from the user and store it in a variable, opr.
Step 5: Based on the user’s input, perform the desired arithmetic operation using if…elif…else statement.
Step 6: Print the result.
Step 7: Stop.

CODING:

RESULT:
Thus, a Python program to implement Arithmetic Calculator using if…elif…else statement has been
successfully executed and the output is verified.
1|Page
EXECUTION AND OUTPUT:

2|Page
EX: NO: 2 MATHEMATICAL FUNCTIONS
DATE:

QUESTION:
Write a Python program to illustrate Mathematical Functions.

AIM:
To write a Python program to illustrate Mathematical Functions.

ALGORITHM:
Step 1: Start.
Step 2: Import the math module.
Step 3: Perform the desired math functions and calculate the result.
Step 4: Print the result.
Step 5: Stop.

CODING:

RESULT:
Thus, a Python program to illustrate Mathematical functions has been successfully executed and the output is
verified.

3|Page
EXECUTION AND OUTPUT:

4|Page
EX: NO: 3 STRING FUNCTIONS
DATE:

QUESTION:
Write a Python program to illustrate String Functions.

AIM:
To write a Python program to illustrate String Functions.

ALGORITHM:
Step 1: Start.
Step 2: Input the strings.
Step 3: Perform the desired string functions.
Step 4: Print the result.
Step 5: Stop.

CODING:

RESULT:
Thus, a Python program to illustrate String functions has been successfully executed and the output is
verified.

5|Page
EXECUTION AND OUTPUT:

6|Page
EX: NO: 4 LIST MANIPULATION METHODS
DATE:

QUESTION:
Write a Python program to illustrate List Manipulation Methods.

AIM:
To write a Python program to illustrate List Manipulation Methods.

ALGORITHM:
Step 1: Start.
Step 2: Read the list elements from the user.
Step 3: Display a menu with various list manipulation methods and get the desired choice from the user.
Step 4: Based on the user’s input, perform the operations
Step 5: Print the new list.
Step 6: Stop.

7|Page
CODING:

RESULT:
Thus, a Python program to illustrate List Manipulation Methods has been successfully executed and the
output is verified.

8|Page
EXECUTION AND OUTPUT:

9|Page
10 | P a g e
EX: NO: 5 TUPLE MANIPULATION METHODS
DATE:

QUESTION:
Write a Python program to illustrate Tuple Manipulation Methods.

AIM:
To write a Python program to illustrate Tuple Manipulation Methods.

ALGORITHM:
Step 1: Start.
Step 2: Read the Tuple elements from the user.
Step 3: Display a menu with various tuple manipulation methods and get the desired choice from the user.
Step 4: Based on the user’s input, perform the operations.
Step 5: Print the result.
Step 6: Stop.

CODING:

RESULT:
Thus, a Python program to illustrate Tuple Manipulation Methods has been successfully executed and the
output is verified.
11 | P a g e
EXECUTION AND OUTPUT:

12 | P a g e
EX: NO: 6 DICTIONARY FUNCTIONS
DATE:

QUESTION:
Write a Python program to illustrate Dictionary Functions.

AIM:
To write a Python program to illustrate Dictionary Functions.

ALGORITHM:
Step 1: Start.
Step 2: Input the dictionaries.
Step 3: Perform the desired dictionary methods.
Step 4: Print the result.
Step 5: Stop.

CODING:

RESULT:
Thus, a Python program to illustrate Dictionary functions has been successfully executed and the output is
verified.

13 | P a g e
EXECUTION AND OUTPUT:

14 | P a g e
EX: NO: 7 RANDOM NUMBER GENERATOR
DATE:

QUESTION:
Write a Python program to implement a Random Number Generator that generates random numbers between 1
and 6 (simulates a dice).

AIM:
To write a Python program to implement a Random Number Generator that generates random numbers between
1 and 6 (simulates a dice).

ALGORITHM:
Step 1: Start.
Step 2: Import the random module.
Step 3: Read the user’s choice to roll the dice, using a variable, say roll.
Step 4: If roll == ‘y’, then roll the dice and generate a random number between 1 and 6 using randint(1, 6).
Step 5: Print the random number.
Step 6: Repeat Steps 4 and 5, if the user’s input is ‘y’ again.
Step 7: Stop.

CODING:

RESULT:
Thus, a Python program to implement a Random Number Generator that generates random numbers between
1 and 6 (simulates a dice) has been successfully executed and the output is verified.
15 | P a g e
EXECUTION AND OUTPUT:

16 | P a g e
EX: NO: 8 READING A TEXT FILE AND DISPLAYING THE NUMBER OF
DATE: VOWELS/ CONSONANTS/ UPPERCASE/ LOWERCASE CHARACTERS

QUESTION:
Write a Python program to read a text file and display the number of Vowels/ Consonants/ Uppercase and
lowercase characters in the file.

AIM:
To write a Python program to read a text file and display the number of Vowels/ Consonants/ Uppercase and
lowercase characters in the file.

ALGORITHM:
Step 1: Start.
Step 2: Create a text file “quotes.txt” and type the following text.

Step 3: In Python IDLE, open the file in read mode.


Step 4: Initialize the counting variables to 0.
Step 5: Initialize a while loop and read every character in the file using read( ).
Step 6: Check if the character is an alphabet and count the number of vowels, consonants, uppercase and
lowercase letters using if…else statements.
Step 7: Print the result.
Step 8: Close the file.
Step 9: Stop.

CODING:

RESULT:
Thus, a Python program to read a text file and display the number of Vowels/ Consonants/ Uppercase and
lowercase characters in the file has been successfully executed and the output is verified.
17 | P a g e
EXECUTION AND OUTPUT:

18 | P a g e
EX: NO: 9 READING A TEXT FILE LINE BY LINE AND DISPLAYING EACH WORD
DATE: SEPARATED BY A #

QUESTION:
Write a Python program to read a text file line by line and display each word separated by a #.

AIM:
To write a Python program to read a text file line by line and display each word separated by a #.

ALGORITHM:
Step 1: Start.
Step 2: Create a text file “quotes.txt” and type the following text.

Step 3: In Python IDLE, open the file in read mode.


Step 4: Initialize a while loop and read the file line by line using readline( ).
Step 5: Split every line into words using split( ) and add # as the separator for each word. Repeat this step for
every other line using for loop.
Step 6: Print the result.
Step 7: Close the file.
Step 8: Stop.

CODING:

RESULT:
Thus, a Python program to read a text file line by line and display each word separated by a # has been
successfully executed and the output is verified.

19 | P a g e
EXECUTION AND OUTPUT:

20 | P a g e
EX: NO: 10 REMOVING ALL THE LINES THAT CONTAIN THE CHARACTER ‘A’
DATE: IN A TEXT FILE AND WRITING IT TO ANOTHER FILE

QUESTION:
Write a Python program to remove all the lines that contain the character ‘a’ in a text file and write it to another
file.

AIM:
To write a Python program to remove all the lines that contain the character ‘a’ in a text file and write it to
another file.

ALGORITHM:
Step 1: Start.
Step 2: Create a text file “poem1.txt” and type the following text.

Step 3: In Python IDLE, open the file in read mode.


Step 4: Open another file say, poem2 in write mode.
Step 5: Initialize a for loop and read every line in “poem1.txt”.
Step 6: Using if statement, write the lines that do not contain the character ‘a’ or ‘A’ onto the file “poem2.txt”.
Step 7: Print the result.
Step 8: Close the files.
Step 9: Stop.

CODING:

RESULT:
Thus, a Python program to remove all the lines that contain the character ‘a’ in a text file and write it to another
file has been successfully executed and the output is verified.

21 | P a g e
EXECUTION AND OUTPUT:

22 | P a g e
EX: NO: 11 CREATING AND SEARCHING A BINARY FILE FOR A GIVEN
DATE: ROLL NUMBER AND DISPLAYING AN APPROPRIATE MESSAGE

QUESTION:
Write a Python program to create a Binary file with name and roll number. Search for a given roll number and
display the name, if not found display an appropriate message.

AIM:
To write a Python program to create a Binary file with name and roll number, search for a given roll number
and display the name, if not found display an appropriate message.

ALGORITHM:
Step 1: Start.
Step 2: Create an empty dictionary say, stud.
Step 3: Create a Binary file and open the file in write mode.
Step 4: Initialize a while loop and get the inputs – rollno and name from the user.
Step 5: Write the records onto the file using dump ( ) and close the file.
Step 6: Now, open the file in read mode.
Step 7: Get the record to be searched from the user.
Step 8: Read the records from the file using load ( ) and search for the roll number entered by the user using if
statement.
Step 9: If the record is found, display the corresponding name. Else display an error message.
Step 10:Close the file.
Step 11:Stop.

23 | P a g e
CODING:

RESULT:
Thus, a Python program to create a Binary file with name and roll number, search for a given roll number and
display the name, if not found display an appropriate message has been successfully executed and the output
is verified.

24 | P a g e
EXECUTION AND OUTPUT:

25 | P a g e
EX: NO: 12 CREATING AND UPDATING A BINARY FILE
DATE:

QUESTION:
Write a Python program to create a Binary file with name, roll number and marks, input a roll number and
update the marks.

AIM:
To write a Python program to create a Binary file with name, roll number and marks, input a roll number and
update the marks.

ALGORITHM:
Step 1: Start.
Step 2: Create an empty dictionary say, stud.
Step 3: Create a Binary file and open the file in write mode.
Step 4: Initialize a while loop and get the inputs – rollno, name and marks from the user.
Step 5: Write the records onto the file using dump ( ) and close the file.
Step 6: Now, open the file in rb+ mode.
Step 7: Get the record to be searched from the user. Locate the current position of the file pointer using tell ( ).
Step 8: Read the records from the file using load ( ) and search for the roll number entered by the user using if
statement.
Step 9: If the record is found, get the marks to be updated from the user and update the same. Else display an
error message.
Step 10:Close the file.
Step 11:Stop.

26 | P a g e
CODING:

RESULT:
Thus, a Python program to create a Binary file with name, roll number and marks, input a roll number and
update the marks has been successfully executed and the output is verified.

27 | P a g e
EXECUTION AND OUTPUT:

28 | P a g e
EX: NO: 13 CREATING AND DISPLAYING THE CONTENTS OF A CSV FILE
DATE:

QUESTION:
Write a Python program to create and display the contents of a CSV file.

AIM:
To write a Python program to create and display the contents of a CSV file.

ALGORITHM:
Step 1: Start.
Step 2: Import csv module.
Step 3: Create a CSV file and open the file in write mode.
Step 4: Create the writer object.
Step 5: Obtain the data from the user and write the records onto the file using writerow( ) and close the file.
Step 6: Now, open the file in read mode.
Step 7: Get the record to be searched from the user.
Step 8: Read the records from the file using reader( ) and display the same.
Step 9: Close the file.
Step 10:Stop.

CODING:

RESULT:
Thus, a Python program to create and display the contents of a CSV file has been successfully executed and
the output is verified.
29 | P a g e
EXECUTION AND OUTPUT:

30 | P a g e
EX: NO: 14 CREATING, READING AND SEARCHING A CSV FILE FOR
DATE: GIVEN USER ID AND DISPLAYING THE APPROPRIATE PASSWORD

QUESTION:
Write a Python program to create, read and search a CSV file for given User ID and display the appropriate
Password.

AIM:
To write a Python program to create, read and search a CSV file for given User ID and display the appropriate
Password.

ALGORITHM:
Step 1: Start.
Step 2: Import csv module.
Step 3: Create a CSV file and open the file in write mode.
Step 4: Create the writer object.
Step 5: Obtain the data from the user and write the records onto the file using writerow( ) and close the file.
Step 6: Now, open the file in read mode.
Step 7: Get the User ID to be searched from the user.
Step 8: Read the records from the file using reader( ) and search for the given User ID.
Step 9: If found, display the corresponding Password. Else, display an error message.
Step 10:Close the file.
Step 11:Stop.

31 | P a g e
CODING:

RESULT:
Thus, a Python program to create, read and search a CSV file for given User ID and display the appropriate
Password has been successfully executed and the output is verified.

32 | P a g e
EXECUTION AND OUTPUT:

33 | P a g e
EX: NO: 15 STACK OPERATIONS USING LIST
DATE:

QUESTION:
Write a Python program to implement Stack Operations using List.

AIM:
To write a Python program to implement Stack Operations using List.

ALGORITHM:
Step 1: Start.
Step 2: Display a menu with various Stack operations and get the desired choice from the user.
Step 3: Based on the user’s input, perform the operations using if…elif…else statement.
Step 4: Print the result.
Step 5: Stop.

CODING:

RESULT:
Thus, a Python program to implement Stack Operations using List has been successfully executed and the
output is verified.
34 | P a g e
EXECUTION AND OUTPUT:

35 | P a g e
36 | P a g e

You might also like