OOPS (Python) Laboratory Manual 2025 1-50 EXP
OOPS (Python) Laboratory Manual 2025 1-50 EXP
Prepared by Approved By
INDEX
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
If number % 2 == 0, it is even.
Otherwise, it is 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 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 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:
ALGORITHM:
Step 1: Start
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 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 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 5: Else, use a loop to multiply numbers from 1 to the given number and store the
result in factorial.
Step 7: End
OUTPUT:
EXP. NO: 15
CHECK WHETHER A GIVEN NUMBER IS PRIME OR NOT. PAGE NO. :
DATE:
AIM:
ALGORITHM:
Step 1: Start
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:
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 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 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 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
sum() function.
Looping through the list and adding each element.
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
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 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 3: Use the swapcase() method to convert uppercase letters to lowercase and
lowercase letters to uppercase.
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 4: Find the sum of elements in each tuple using the sum() function.
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 3: Convert each integer in the tuple to a string using map(str, tuple).
Step 5: Convert the joined string back into an integer using int().
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 4: Find the sum of elements in each tuple using the sum() function.
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 5: End
OUTPUT:
EXP. NO: 27
PROGRAM TO REVERSE A TUPLE. PAGE NO. :
DATE:
AIM:
ALGORITHM:
Step 1: Start
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 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 3: Use the len() function to find 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 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:
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: