0% found this document useful (0 votes)
26 views54 pages

OOPS (Python) Laboratory Manual 2025 1-50 EXP

The document outlines a laboratory manual for an Object-Oriented Programming course using Python at SRI SHAKTHI Institute of Engineering and Technology. It includes a list of experiments with aims, algorithms, and outputs for various Python programming tasks, such as reading user input, performing arithmetic operations, and checking conditions. The manual serves as a guide for students to practice and understand fundamental programming concepts using Python.

Uploaded by

raswathi60
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views54 pages

OOPS (Python) Laboratory Manual 2025 1-50 EXP

The document outlines a laboratory manual for an Object-Oriented Programming course using Python at SRI SHAKTHI Institute of Engineering and Technology. It includes a list of experiments with aims, algorithms, and outputs for various Python programming tasks, such as reading user input, performing arithmetic operations, and checking conditions. The manual serves as a guide for students to practice and understand fundamental programming concepts using Python.

Uploaded by

raswathi60
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 54

SRI SHAKTHI

INSTITUTE OF ENGINEERING AND TECHNOLOGY


(An Autonomous Institution) Affiliated to Anna University, Chennai
Re-Accredited by NAAC with "A", Recognized by UGC with Section 2(f) and 12(B) NBA
Accredited UG Programmes: Agri, BME, BT, CSE, ECE, EEE, MECH and IT
Coimbatore - 641 062, L& T By Pass, Tamil Nadu, India

21AM212 - OBJECTED ORIENTED PROGRAMMING


USING PYTHON LABORATORY
(Regulation 2021)

DEPARTMENT OF COMPUTER SCIENCE AND

ENGINEERING (CYBER SECURITY)

Prepared by Approved By
INDEX

EXP.NO DATE NAME OF THE EXPERIMENT PAGE.NO MARKS SIGN


1 PRINT HELLO WORLD PROGRAM
TO READ A VALUE FROM THE USER
2
AND DISPLAY ITS TYPE
READ AN INTEGER VALUE FROM
3
THE USER
READ THREE FLOATING-POINT
4
VALUES FROM THE USER
READ AND DISPLAY THE
CUSTOMER'S NAME, AGE, PRODUCT
5
QUANTITY, AND PRODUCT PRICE
FROM THE USER
PERFORM ADDITION,
6 SUBSTARCTION, MULTIPLICATION
AND DIVISION USING MODULO
READ THE BOOLEAN VALUES AND
7 PERFORM LOGICAL OPERATIONS -
AND, OR, and NOT
PYTHON PROGRAM THAT CHECKS
WHETHER A GIVEN NUMBER IS
8
EVEN OR ODD USING A
CONDITIONAL EXPRESSION.
READ THE TEMPERATURE IN
9 CELSIUS AND PRINTS THE
TEMPERATURE IN FAHRENHEIT.
SWAP TWO NUMBERS USING A
10
THIRD VARIABLE
CHECK WHETHER A GIVEN
CHARACTER IS PRESENT IN A
11 STRING USING MEMBERSHIP
OPERATOR AND CONDITIONAL
EXPRESSION.
GET A YEAR AS INPUT FROM THE
USER AND CHECK WHETHER THE
12
GIVEN YEAR IS A LEAP YEAR OR
NOT.
CHECK WHETHER A GIVEN NUMBER
13
IS ODD OR EVEN.
FIND THE FACTORIAL OF A GIVEN
14
NUMBER.
CHECK WHETHER A GIVEN NUMBER
15
IS PRIME OR NOT.
TO READ A NUMBER (0-6) AND PRINT
16 THE CORRESPONDING WEEKDAY
NAME.
CHECK WHETHER A GIVEN NUMBER
17
IS A 2-DIGIT NUMBER OR NOT
18 REVERSE A LIST
19 SUM ALL THE ITEMS IN A LIST.
CHECK IF A GIVEN LIST IS IN
20
ASCENDING ORDER OR NOT.
INTERCHANGE THE FIRST AND LAST
21
ELEMENTS IN A LIST.
CONVERTS UPPERCASE LETTERS TO
22
LOWERCASE AND VICE-VERSA
FIND THE SUM OF ELEMENTS IN
23
EACH TUPLE IN A LIST.
TO CONVERT A TUPLE OF POSITIVE
24
INTEGERS INTO A SINGLE INTEGER.
TO PRINT THE SUM OF ELEMENTS IN
25
EACH TUPLE IN A LIST.
26 PROGRAM TO JOIN TWO TUPLES.
27 PROGRAM TO REVERSE A TUPLE.
PRINT THE FIRST AND LAST
28
ELEMENT IN A TUPLE
29 FIND THE LENGTH OF A TUPLE.
CHECK WHETHER A STRING IS A
30
PALINDROME OR NOT.
31 DIFFERENT NUMBER DATATYPE
32 ARITHMETIC OPERATIONS
33 CONCATENATE A STRING
34 PRINT THE TIME FORMAT
35 APPEND AND REMOVE
36 WORKING WITH TUPLES
37 WORKING WITH DICTIONARY
38 LARGEST OF THREE NUMBER
CONVERT CELCIUS AND
39
FAHRENHIET
40 PATTERN USING NESTED FOR LOOP
PRINT THE PRIME NUMBER LESS
41
THAN 20
FACTORIAL OF NUMBER USING
42
RECURSION
43 RIGHT ANGLED TRIANGLE
44 FIBONACCI SERIES
TO DEFINE A MODULE AND IMPORT
45
A SPECIFIC FUNCTION
46 COPY FILE
TO PRINT ALL OF THE UNIQUE
47
WORDS
TO CONVERT AN INTEGER TO
48
ROMAIN NUMERAL
49 TO IMPLEMENT POW(X,N)
50 REVERSE A STRING WORD BY WORD
EXP. NO: 01
PRINT HELLO WORLD PROGRAM PAGE NO. :
DATE:

AIM:
To write a Python program to print "Hello, World!".

ALGORITHM:
Step 1: Start
Step 2: Display "Hello, World!".
Step 3: Stop

OUTPUT:
EXP. NO: 02
TO READ A VALUE FROM THE USER AND DISPLAY ITS TYPE PAGE NO. :
DATE:

AIM:
To Write a program to read a value from the user and display its type.

ALGORITHM:
Step 1: Start
Step 2: Read a value from the user
Step 3: Use the type() function to determine the data type of the value
Step 4: Display the data type of the entered value
Step 5: Stop

OUTPUT:
EXP. NO: 03
READ AN INTEGER VALUE FROM THE USER PAGE NO. :
DATE:

AIM:
To write a Python program to read an integer value from the user and display it.

ALGORITHM:
Step 1: Start
Step 2: Read an integer value from the user
Step 3: Display the entered integer value
Step 4: Stop

OUTPUT:
EXP. NO: 04
DATE:
READ THREE FLOATING-POINT VALUES FROM THE USER PAGE NO. :

AIM:
To write a Python program to read three floating-point values from the user and display
them.

ALGORITHM:
Step 1: Start
Step 2: Read three floating-point values from the
user Step 3: Display the entered floating-point values
Step 4: Stop

OUTPUT:
EXP. NO: 05 READ AND DISPLAY THE CUSTOMER'S NAME, AGE, PRODUCT
PAGE NO. :
DATE: QUANTITY, AND PRODUCT PRICE FROM THE USER

AIM:
To write a Python program to read and display the customer name, age, product
quantity, and product price from the user.

ALGORITHM:
Step 1: Start
Step 2: Read the customer name from the user
Step 3: Read the customer age from the user
Step 4: Read the product quantity from the user
Step 5: Read the product price from the user
Step 6: Display the entered details
Step 7: Stop

OUTPUT:
EXP. NO: 06 PERFORM ADDITION,SUBSTARCTION,MULTIPLICATION AND
PAGE NO. :
DATE: DIVISION USING MODULO

AIM:
To write a Python program that performs addition, subtraction, multiplication, division
modulo operations on two numbers.

ALGORITHM:

Step 1: Start

Step 2: Read the first number from the user and store it in a variable.

Step 3: Read the second number from the user and store it in a variable.

Step 4: Perform addition of the two numbers and display the result.

Step 5: Perform subtraction of the two numbers and display the result.
Step 6: Perform multiplication of the two numbers and display the result.
Step 7: Perform division of the two numbers and display the result.
Step 8: Perform modulo operation of the two numbers and display the result.

Step 9: End

OUTPUT:
EXP. NO: 07 READ THE BOOLEAN VALUES AND PERFORM LOGICAL
PAGE NO. :
DATE: OPERATIONS - AND, OR, and NOT

AIM:
To develop a Python program that reads Boolean values from the user and performs
logical operations: AND, OR, and NOT.
ALGORITHM:

Step 1: Start

Step 2: Read the first Boolean value (True/False) from the user and store it in a
variable.

Step 3: Read the second Boolean value (True/False) from the user and store it in
another variable.

Step 4: Perform the AND (and) operation between the two values and display the
result.

Step 5: Perform the OR (or) operation between the two values and display the result.

Step 6: Perform the NOT (not) operation on the first Boolean value and display the
result.

Step 7: End

OUTPUT:
EXP. NO: 08 PYTHON PROGRAM THAT CHECKS WHETHER A GIVEN NUMBER
PAGE NO. :
DATE: IS EVEN OR ODD USING A CONDITIONAL EXPRESSION.

AIM:
To write a Python program that checks whether a given number is even or odd using a
conditional expression.

ALGORITHM:

Step 1: Start

Step 2: Read a number from the user and store it in a variable.

Step 3: Use a conditional expression to check if the number is divisible by 2:

 If number % 2 == 0, it is even.
 Otherwise, it is odd.

Step 4: Display whether the number is even or odd.

Step 5: End

OUTPUT:
EXP. NO: 09 PYTHON PROGRAM THAT READS THE TEMPERATURE IN
PAGE NO. :
DATE: CELSIUS AND PRINTS THE TEMPERATURE IN FAHRENHEIT.

AIM:
To write a python program that reads the temperature in celsius and prints the
temperature in fahrenheit.
ALGORITHM:

step 1: start

step 2: read the temperature in celsius from the user and store it in a variable.

step 3: convert the temperature to fahrenheit using the formula:

fahrenheit=(celsius×95)+32fahrenheit = (celsius \times \


frac{9}{5}) + 32fahrenheit=(celsius×59 )+32

step 4: display the temperature in fahrenheit.

step 5: end

OUTPUT:
EXP. NO: 10
SWAP TWO NUMBERS USING A THIRD VARIABLE. PAGE NO. :
DATE:

AIM:
To write a Python program to swap two numbers using a third variable.
ALGORITHM:

Step 1: Start

Step 2: Read two numbers from the user and store them in variables a and b.

Step 3: Create a third variable temp and assign a to it.

Step 4: Assign the value of b to a.

Step 5: Assign the value of temp to b.

Step 6: Display the swapped values of a and b.

Step 7: End

OUTPUT:
CHECK WHETHER A GIVEN CHARACTER IS PRESENT IN A
EXP. NO: 11
STRING USING MEMBERSHIP OPERATOR AND CONDITIONAL PAGE NO. :
DATE:
EXPRESSION.

AIM:

To write a Python program to check whether a given character is present in a string


using the membership operator and a conditional expression.

ALGORITHM:

Step 1: Start

Step 2: Read a string from the user and store it in a variable.

Step 3: Read a character from the user to search in the string.

Step 4: Use the membership operator (in) to check if the character is present in the
string.

Step 5: Use a conditional expression to display whether the character is found or not.

Step 6: End

OUTPUT:
EXP. NO: 12 GET A YEAR AS INPUT FROM THE USER AND CHECK WHETHER
PAGE NO. :
DATE: THE GIVEN YEAR IS A LEAP YEAR OR NOT.

AIM:

To write a Python program to get a year as input from the user and check whether the
given year is a leap year or not.

ALGORITHM:

Step 1: Start

Step 2: Read a year from the user and store it in a variable.

Step 3: Check if the year is divisible by 4.

 If true, check if the year is also divisible by 100.


o If true, check if the year is divisible by 400.
 If true, it is a leap year.
 Else, it is not a leap year.
o Else, it is a leap year.
 Else, it is not a leap year.

Step 4: Display whether the year is a leap year or not.

Step 5: End

OUTPUT:
EXP. NO: 13
CHECK WHETHER A GIVEN NUMBER IS ODD OR EVEN. PAGE NO. :
DATE:

AIM:
To write a Python program to check whether a given number is odd or even.

ALGORITHM:

Step 1: Start

Step 2: Read a number from the user and store it in a variable.

Step 3: Check if the number is divisible by 2:

If number % 2 == 0, print that it is even.


Else, print that it is odd.

Step 4: Display whether the number is odd or even.

Step 5: End

OUTPUT:
EXP. NO: 14
FIND THE FACTORIAL OF A GIVEN NUMBER. PAGE NO. :
DATE:

AIM:
To write a Python program to find the factorial of a given number.
ALGORITHM:

Step 1: Start

Step 2: Read a number from the user and store it in a variable.

Step 3: Initialize a variable factorial = 1.

Step 4: If the number is 0 or 1, print factorial = 1.

Step 5: Else, use a loop to multiply numbers from 1 to the given number and store the
result in factorial.

Step 6: Display the factorial value.

Step 7: End

OUTPUT:
EXP. NO: 15
CHECK WHETHER A GIVEN NUMBER IS PRIME OR NOT. PAGE NO. :
DATE:

AIM:

To write a Python program to check whether a given number is prime or not.

ALGORITHM:

Step 1: Start

Step 2: Read a number from the user and store it in a variable.

Step 3: If the number is less than or equal to 1, print that it is not a prime number.

Step 4: Initialize a loop from 2 to the square root of the number (inclusive) and check if
the number is divisible by any value in this range:

If divisible, print that it is not a prime number and exit.


Otherwise, continue the loop.

Step 5: If no factors are found, print that the number is a prime number.

Step 6: End

OUTPUT:
EXP. NO: 16 TO READ A NUMBER (0-6) AND PRINT THE CORRESPONDING
PAGE NO. :
DATE: WEEKDAY NAME.

AIM:
To write a Python program to read a number (0-6) and print the corresponding weekday
name.
ALGORITHM:

Step 1: Start

Step 2: Read a number (0-6) from the user and store it in a variable.

Step 3: Use a conditional statement or a list to map the number to the corresponding
weekday name

Step 4: If the number is outside the range (0-6), print an error message.

Step 5: Display the corresponding weekday name.

Step 6: End

OUTPUT:
EXP. NO: 17 CHECK WHETHER A GIVEN NUMBER IS A 2-DIGIT NUMBER OR
PAGE NO. :
DATE: NOT

AIM:
To write a Python program to check whether a given number is a 2-digit number or not.
ALGORITHM:

Step 1: Start

Step 2: Read a number from the user and store it in a variable.

Step 3: Check if the number is between 10 and 99 (inclusive) or -10 and -99 (inclusive).

Step 4: If the condition is true, print that it is a 2-digit number. Else, print that it is not a
2-digit number.

Step 5: End

OUTPUT:
EXP. NO: 18
REVERSE A LIST PAGE NO. :
DATE:

AIM:
To write a Python program to reverse a list.
ALGORITHM:

Step 1: Start

Step 2: Read a list from the user.

Step 3: Reverse the list using one of the following methods:

Using reverse() method.


Using slicing ([::-1]).
Using reversed() function.

Step 4: Display the reversed list.

Step 5: End

OUTPUT:
EXP. NO: 19
SUM ALL THE ITEMS IN A LIST. PAGE NO. :
DATE:

AIM:
To write a Python program to sum all the items in a list.
ALGORITHM:

Step 1: Start

Step 2: Read a list of numbers from the user.

Step 3: Calculate the sum of all elements in the list using:

sum() function.
Looping through the list and adding each element.

Step 4: Display the total sum.

Step 5: End

OUTPUT:
EXP. NO: 20
CHECK IF A GIVEN LIST IS IN ASCENDING ORDER OR NOT. PAGE NO. :
DATE:

AIM:
To write a Python program to check if a given list is in ascending order or not.
ALGORITHM:

Step 1: Start

Step 2: Read a list of numbers from the user.

Step 3: Compare the list with its sorted version using:

sorted() function.
Direct comparison (list == sorted(list)).

Step 4: If the list matches its sorted version, print that it is in ascending order.
Otherwise, print that it is not in ascending order.

Step 5: End

OUTPUT:
EXP. NO: 21 INTERCHANGE THE FIRST AND LAST ELEMENTS IN A LIST.
PAGE NO. :
DATE:

AIM:
To write a Python program to interchange the first and last elements in a list.
ALGORITHM:

Step 1: Start

Step 2: Read a list of elements from the user.

Step 3: Check if the list has at least two elements.

Step 4: Swap the first and last elements of the list

using: Indexing (list[0], list[-1]).

Step 5: Display the updated list.

Step 6: End

OUTPUT:
EXP. NO: 22 CONVERTS UPPERCASE LETTERS TO LOWERCASE AND
PAGE NO. :
DATE: VICE-VERSA

AIM:
To write a Python program that converts uppercase letters to lowercase and vice versa.
ALGORITHM:

Step 1: Start

Step 2: Read a string from the user.

Step 3: Use the swapcase() method to convert uppercase letters to lowercase and
lowercase letters to uppercase.

Step 4: Display the modified string.

Step 5: End

OUTPUT:
EXP. NO: 23 FIND THE SUM OF ELEMENTS IN EACH TUPLE IN A LIST.
PAGE NO. :
DATE:

AIM:
To write a Python program to find the sum of elements in each tuple in a list.
ALGORITHM:

Step 1: Start

Step 2: Read a list of tuples from the user.

Step 3: Iterate through each tuple in the list.

Step 4: Find the sum of elements in each tuple using the sum() function.

Step 5: Store and display the sum of each tuple.

Step 6: End

OUTPUT:
EXP. NO: 24 TO CONVERT A TUPLE OF POSITIVE INTEGERS INTO A
PAGE NO. :
DATE: SINGLE INTEGER.

AIM:

To write a Python program to convert a tuple of positive integers into a single integer.

ALGORITHM:

Step 1: Start

Step 2: Read a tuple of positive integers from the user.

Step 3: Convert each integer in the tuple to a string using map(str, tuple).

Step 4: Join the string representations together using ''.join().

Step 5: Convert the joined string back into an integer using int().

Step 6: Display the final integer.

Step 7: End

OUTPUT:
EXP. NO: 25 TO PRINT THE SUM OF ELEMENTS IN EACH TUPLE IN A
PAGE NO. :
DATE: LIST.

AIM:
To write a Python program to print the sum of elements in each tuple in a list.
ALGORITHM:

Step 1: Start

Step 2: Read a list of tuples from the user.

Step 3: Iterate through each tuple in the list.

Step 4: Find the sum of elements in each tuple using the sum() function.

Step 5: Print the sum of each tuple.

Step 6: End

OUTPUT:
EXP. NO: 26
PROGRAM TO JOIN TWO TUPLES. PAGE NO. :
DATE:

AIM:
To write a Python program to join two tuples.
ALGORITHM:

Step 1: Start

Step 2: Read two tuples from the user.

Step 3: Use the + operator to join both tuples.

Step 4: Display the resulting tuple.

Step 5: End

OUTPUT:
EXP. NO: 27
PROGRAM TO REVERSE A TUPLE. PAGE NO. :
DATE:

AIM:

To write a Python program to reverse a tuple.

ALGORITHM:

Step 1: Start

Step 2: Read a tuple from the user.

Step 3: Reverse the tuple using slicing [::-1].

Step 4: Display the reversed tuple.

Step 5: End

OUTPUT:
EXP. NO: 28 PRINT THE FIRST AND LAST ELEMENT IN A TUPLE.
PAGE NO. :
DATE:

AIM:
To write a Python program to print the first and last element in a tuple.
ALGORITHM:

Step 1: Start

Step 2: Read a tuple from the user.

Step 3: Extract the first element using tuple[0].


Step 4: Extract the last element using tuple[-1].
Step 5: Display the first and last element.

Step 6: End

OUTPUT:
EXP. NO: 29
FIND THE LENGTH OF A TUPLE. PAGE NO. :
DATE:

AIM:
To write a Python program to find the length of a tuple.
ALGORITHM:

Step 1: Start

Step 2: Read a tuple from the user.

Step 3: Use the len() function to find the length of the tuple.

Step 4: Display the length of the tuple.

Step 5: End

OUTPUT:
EXP. NO: 30
CHECK WHETHER A STRING IS A PALINDROME OR NOT. PAGE NO. :
DATE:

AIM:
To write a Python program to check whether a string is a palindrome or not.
ALGORITHM:

Step 1: Start

Step 2: Read a string from the user.

Step 3: Convert the string to lowercase to ensure case insensitivity.

Step 4: Reverse the string using slicing [::-1].

Step 5: Compare the original string with the reversed string.

Step 6: If both are the same, print "The string is a palindrome," else print "The string is
not a palindrome."

Step 7: End

OUTPUT:
EXP. NO: 31
DIFFERENT NUMBER DATATYPE PAGE NO. :
DATE:

AIM:
To develop a python program to demonstrate different data type in Python

ALGORITHM:
Step1: Start
Step 2: Declare variables and its values.
Step 3: Using type function find datatype of given value
Step 4: Print output
Step 5: stop.

OUTPUT:
EXP. NO: 32
ARITHMETIC OPERATIONS PAGE NO. :
DATE:

AIM:
To develop a python program to demonstrate arithmetic operations in python
ALGORITHM:
Step1: Start
Step 2: Declare variables and types.
Step3: Using various arithmetic operators perform various arithmetic operations.
Step 4: Print output.
Step5: $top

OUTPUT:
EXP. NO: 33
CONCATENATE A STRING PAGE NO. :
DATE:

AIM:
To write a program to create, concatenate and print a string from a given string. and
accessing sub-string

ALGORITHM:
Step1: Start the program
Step2: Initialize a pi with the value 3.14 and s and with the value.
Step3: Print "the value of sis: {s}", "the value of vis: {v}"
Step4: Concatenate the strings sand v
Step 5: Print "after concatenating sand & the string is: string add
Step 6: Create a string "The value of pi is" followeed by the string
Di Step 7: Print the text string
Step 8: Stop the program

OUTPUT:
EXP. NO: 34
PRINT THE TIME FORMAT PAGE NO. :
DATE:

AIM:
To write a python script to print the Current date “Sun May 29 the following format
02:26:23 IST 2017”

ALGORITHM:
Step1: Start the program
Step2: Import the 'time' and 'datetime' module.
Step3: Assign the current using date and time x= date time date time.now()
Step 4: Pass the "%c" format specifier to strftime a to represent date and time in local
specific format
Step5: Print the formatted date and time using the print function
Step 6: $top the program

OUTPUT:
EXP. NO: 35
APPEND AND REMOVE PAGE NO. :
DATE:

AIM:
To write a python program to create, append and remove lists in python

ALGORITHM:
Step 1: Start the program
Step 2: Greate an empty list using the square brackets: my-list = [].
Step 3: Use the append() method to add flems to the end of the list.
Step 4: Use the remove() method to remove a specific item from the
list Step 5: Display the list
Step 6: Stop the program

OUTPUT:
EXP. N`O: 36
WORKING WITH TUPLES PAGE NO. :
DATE:

AIM:
To write a python program to create, append and remove lists in python.
ff
ALGORITHM:
Step 1: Start the program
Step 2: Greate an empty list using the square brackets: my-list = [].
Step3: Use the append() method to add flems to the end of the list.
Step4: Use the remove() method to remove a specific item from the list
Step5: Display the list
Step6: Stop the program

OUTPUT:
EXP. NO: 37
WORKING WITH DICTIONARY PAGE NO. :
DATE:

AIM:
To write a program to demonstrate working with dictionaries in python.

ALGORITHM:
Step1: Start the program.
Step2: Creating a dictionary
Step3: Changing Index (updating values)
Step 4: Finding length.
Step5: Copy the dictionary: new-dict> my-dict.copy
Remove a key-value pair: delmy-dict [key-to-remove ]
Step 6: Stop the program

OUTPUT:
EXP. NO: 38
LARGEST OF THREE NUMBER PAGE NO. :
DATE:

AIM:
To write a python program to find largest of three numbers

ALGORITHM:
Step 1: Start the program
Step 2: Input three numbers: num 1, num 2 and num 3
Step3: Compare the three numbers wing statements (if, elif)
Step4: Print largest number print("The largest numbers:")
Step5: stop the program

OUTPUT:
EXP. NO: 39
CONVERT CELCIUS AND FAHRENHIET PAGE NO. :
DATE:

AIM:
To write a python program to convert to Fahrenheit

ALGORITHM:
Step 1: Start the program
Step2: Read the temperature in Celsius (C).
Step3: Calculate Fahrenhiet using:
F - (c * 9 / 5) + 32 and display it.
Step 4: Stop the program

OUTPUT:
EXP. NO: 40
PATTERN USING NESTED FOR LOOP PAGE NO. :
DATE:

AIM:
To write a python program to construct the following pattern wing nested for loop

ALGORITHM:
Step1: Start the program.
Step 2: Read the no of rows for the pattern(n)
Step3: Loop from i = 1 to n
Steps: Print number of stars followed by a new live
$tep5: Loop from i = n- 1 to 1
Steps: Print i number of stars followed by a new line
Step 1: Stop the program

OUTPUT:
EXP. NO: 41
PRINT THE PRIME NUMBER LESS THAN 20 PAGE NO. :
DATE:

AIM:
To write a Python program to print prime numbers less than 20

ALGORITHM:
Step 1: Start the program.
Step 2: Loop from num = 2 to 19 (inclusive).
Step 3: Set is prime = True.
Step 4: Loop from divisor = 2 to the square root of num.
Step 5: If num is divisible by divisor, set is prime = False and break.
Step 6: If is prime is True, print num.
Step 7: Stop the program

OUTPUT:
EXP. NO: 42
FACTORIAL OF NUMBER USING RECURSION PAGE NO. :
DATE:

AIM:
To write a Python program to find the factorial of a number using recursion.

ALGORITHM:
Step 1:

Step1: Start the program.


Step 2: Read the input number n from the user.
Step 3: Define a function factorial(n):
(i) If n is 0 or 1, return 1.
(ii) Otherwise, return n * factorial(n-1).
Step 4: Call the factorial(n) function with the user-provided value.
Step 5: Display the result.
Step 6: Stop the program

OUTPUT:
EXP. NO: 43
RIGHT ANGLED TRIANGLE PAGE NO. :
DATE:

AIM:
To write a python program indicate not the triangle is a right angled triangle.
ALGORITHM:
Step 1: Start the program
Step 2: Read the length of the three sides. of the triangle (a,b,c)
Step 3: Sort the sides in ascending order: Aides [a, b]
Step 4: Calculate sum of short-sides = sides [0] ^2 + side [1] ^2
Step 5: Calculate Longest-side-squared sides [2 ] ^2
Step 6: 28 sum of short-sales equals. Longest-side-squared, then print the triangle is
a right-angled triangle
Step 7: Else, print "the triangle is not a right-angled triangle
step 8: Stop the program.

OUTPUT:
EXP. NO: 44
FIBONACCI SERIES PAGE NO. :
DATE:

AIM:
To write a python program to define a module to find Fibonacci numbers to another
program. and import the module

ALGORITHM:
Step1: Start
Step 2: Import the Fibonacci module
Step 3: Read the input for Fibonacci number Index (7) 1
Step 4: Call Fibonacci function.
Step 5 : Display result
Step 6: Stop.

OUTPUT:
EXP. NO: 45
TO DEFINE A MODULE AND IMPORT A SPECIFIC FUNCTION PAGE NO. :
DATE:

AIM:
To write a python program to define and import a to another program. specific function a
module in that module

ALGORITHM:
Step 1: start
Step 2: Import specific function my-function from my modulo
Step 3: Read the input for the parameter
Step 4: Call the imported parameter my- fun with input
Step 5: Display result
Step 6: Stop

OUTPUT:
EXP. NO: 46
COPY FILE PAGE NO. :
DATE:

AIM:
To write a script named copyfile.py. The contents of the first file should be input and
written to the second file

ALGORITHM:
Step1: Start
Step 2: Open the input file as file.
Step 3: Open the output file in write mode.
Step 4: For line input Output Line
Step 5: Prent "JOB DONE".
Step 6: Stop

OUTPUT:
EXP. NO: 47
TO PRINT ALL OF THE UNIQUE WORDS PAGE NO. :
DATE:

AIM:
To write a program that input a text. file. the program should print all the unique words
in the file in alphabetical order

ALGORITHM:
Step 1: Start
Step 2: Open the specified file for reading.
Step 3:iterate through each line in opened file
Step4: Remove spaces from the line string split() method
Step5: Split line using split() method
Step6: If the element is already present, skip to the next iteration
Step 7: Stop

OUTPUT:
EXP. NO: 48
TO CONVERT AN INTEGER TO ROMAIN NUMERAL PAGE NO. :
DATE:

AIM:
To write a python class to convert to a roman numeral to an integer

ALGORITHM:
Step1: Start
Step 2: Define a class named roman solution
Step 3: Inside the class, define a int-to-Roman (num) method named
3.1 Create two lists to the integer values val and syb that correspond roman numeral
symbols and their corresponding
3.2 : Initialize an empty using roman num to store the roman numeral
representation 33: Initialize an index i to o
3.4: Check if the Input num is less than I on greater than 3999. If it is, an error message.
Step 4: If the number is within the valid range
4.1 : Enter awhile loop that continues until num becomes O.
4.2 : Check if subtracting the value at index: from num result is a non-negative vol
Step 5: Outside the class definition.
Step 6: Stop the program.

OUTPUT:
EXP. NO: 49
TO IMPLEMENT POW(X,N) PAGE NO. :
DATE:

AIM:
To write a Python class to implement pow(x, m)

ALGORITHM:
Step 1:Start the program.
Step 2:Define a class PyPower and a method power(x, n).
Step 3:Inside the power(x, n) method:
Step 3.1: Print the values of x and n.
Step 3.2: Calculate x raised to the power n using x ** n.
Step 3.3: Print the calculated result.
Step 4:Prompt the user to input x (base) as a floating-point number.
Step 5:Prompt the user to input n (power) as a floating-point number.
Step 6:Create an instance of the PyPower class.
Step 7:Call the power(x, n) method.
Step 8:Stop the program

OUTPUT:
EXP. NO: 50
REVERSE A STRING WORD BY WORD PAGE NO. :
DATE:

AIM:
To write a Python class to reverse a string word by word.

ALGORITHM:
Step 1: Start the program.
Step 2: Read the input string S.
Step 3: Trim any leading or trailing spaces from S.
Step 4: Split S into a list of words using spaces as a delimiter.
Step 5: Reverse the order of words in the list.
Step 6: Join the reversed words back into a single string with spaces.
Step 7: Return the reversed string.
Step 8: Stop

OUTPUT:

You might also like