Python Record
Python Record
Python Record
AIM:
To write a program to perform different Arithmetic Operations on numbers in
python.
ALGORITHM:
Step 1: Start the program.
Step 2: Initialize variables 'a' and 'b' to be integers and prompt the user to input a
value for 'a' and 'b'.
Step 3: Perform addition, subtraction, multiplication, division, remainder,
exponent, and floor division operations on 'a' and 'b'
Step 4: Print the results of each operation.
Step 5: Stop the program.
2
PROGRAM:
# arithmetic_operations.py
a=int(input("Enter a value ")) #input() takes data from console at runtime as string.
b=int(input("Enter b value ")) #typecast the input string to int.
print("Addition of a and b ",a+b)
print("Subtraction of a and b ",a-b)
print("Multiplication of a and b ",a*b)
print("Division of a and b ",a/b)
print("Remainder of a and b ",a%b)
print("Exponent of a and b ",a**b) #exponent operator (a^b)
print("Floor division of a and b ",a//b) # floor division
3
OUTPUT:
E:\Python>python arithmetic_operations.py
Enter a value 3
Enter b value 4
Addition of a and b 7
Subtraction of a and b -1
Multiplication of a and b 12
Division of a and b 0.75
Remainder of a and b 3
Exponent of a and b 81
Floor division of a and b 0
RESULT:
Thus, the program to perform different arithmetic operations on numbers in
python was written and executed successfully.
4
Date :
AIM:
To write a program to create, concatenate and print a string and accessing sub-
string from a given string.
ALGORITHM:
Step 1: Start the program.
Step 2: Initialize variables 's1' and 's2' to be strings and prompt the user to input
a value for 's1' and 's2'.
Step 3: Print the values of 's1' and 's2'.
Step 4: Concatenate and print the strings 's1' and 's2'.
Step 5: Create and print a substring of 's1' by using string slicing.
Step 6: Stop the program.
5
PROGRAM:
# string_manipulation.py
s1=input("Enter first String : ")
s2=input("Enter second String : ")
print("First string is : ",s1)
print("Second string is : ",s2)
print("concatenations of two strings :",s1+s2)
print("Substring of given string :",s1[1:4])
6
OUTPUT:
E:\Python>python string_manipulation.py
Enter first String : Hello
Enter second String : World
First string is : Hello
Second string is : World
concatenations of two strings : HelloWorld
Substring of given string : ell
RESULT:
Thus, the program to create, concatenate and print a string and accessing sub-
string from a given string in python was written and executed successfully.
7
AIM:
To write a python program to compute the distance between two points taking
input from the user (Pythagorean Theorem)
ALGORITHM:
Step 5: Calculate the distance between the two points using the Pythagorean
theorem
Step 6: Print the distance between the two points
Step 7: Stop the program
8
PROGRAM:
import math;
x1=int(input("Enter x1--->"))
y1=int(input("Enter y1--->"))
x2=int(input("Enter x2--->"))
y2=int(input("Enter y2--->"))
res = math.sqrt(d1+d2)
OUTPUT:
Enter x1--->10
Enter y1--->20
Enter x2--->15
Enter y2--->19
RESULT:
Thus, the program to find the distance between two points in python was
written and executed successfully.
10
Date :
AIM:
ALGORITHM:
Step 2: Get input for num1, num2 and num3 from the user
Step 3: Check if num1 is greater than both num2 and num3, if so set largest to
num1
Step 4: If not, check if num2 is greater than both num1 and num3, if so set
largest to num2
PROGRAM:
# week8.py
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
num3 = int(input("Enter third number: "))
OUTPUT 1:
E:\Python>python week8.py
Enter first number: 400
Enter second number: 500
Enter third number: 200
The largest number is 500
OUTPUT 2:
Enter first number: 10
Enter second number: 12
Enter third number: 14
The largest number is 14.0
OUTPUT 3:
Enter first number: -1
Enter second number: 0
Enter third number: -3
The largest number is 0.0
RESULT:
Thus, the program to find the largest of three numbers in Python was written
and executed successfully.
13
Date :
AIM:
To write a program to check whether the given number is even number or not.
ALGORITHM:
Step 3: Check if the number is even by using the modulus operator to determine
PROGRAM:
num = int (input (“Enter any number to test whether it is odd or even: “)
if (num % 2) == 0:
else:
OUTPUT:
887
887 is odd.
RESULT:
Thus, the program to check whether the given number is even number or not in
Python was written and executed successfully.
16
AIM:
To write a python program to prints the prime numbers less than 100.
ALGORITHM:
Step 4: Iterate through each number in the range from 2 to the upper limit
Step 5: For each number, check if it is divisible by any number between 2 and
itself
Step 6: If the number is not divisible by any other number, print it as a prime
number
PROGRAM:
# week11.py
print("Prime numbers between 1 and 100 are:")
ulmt=100;
for num in range(ulmt):
# prime numbers are greater than 1
if num > 1:
for i in range(2,num):
if (num % i) == 0:
break
else:
print(num)
18
OUTPUT:
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73
79 83 89 97
RESULT:
Thus, the program to print the prime numbers less than 100 in python was
written and executed successfully.
19
Ex. No. 4.a SUM OF ALL NUMBERS STORED IN A LIST USING LOOPS
Date :
AIM:
To write a python program to find the sum of all numbers stored in a list using
loops.
ALGORITHM:
Step 1: Start the program
Step 2: Create a list of numbers
Step 3: Set a variable sum to 0
Step 4: Iterate through each number in the list
Step 5: For each number, add it to the sum variable
Step 6: Print the final sum of all the numbers in the list
Step 7: Stop the program
20
PROGRAM:
# List of numbers
numbers = [6, 5, 3, 8, 4, 2, 5, 4, 11]
OUTPUT:
The sum is 48
RESULT:
Thus, the program to find the sum of all numbers stored in a list using loops in
python was written and executed successfully.
22
AIM:
To write a python program to print sum of negative numbers, positive even
numbers and positive odd numbers in a list
ALGORITHM:
Step 2: Get the number of elements that will be in the list from the user
Step 3: Create an empty list and get input for each element from the user
Step 6: If the element is positive, check if it is even or odd and add it to the
appropriate sum
Step 8: Print the sum of all positive even numbers, the sum of all positive odd
PROGRAM:
n=int(input("Enter the number of elements to be in the list:"))
b=[]
for i in range(0,n):
a=int(input("Element: "))
b.append(a)
sum1=0
sum2=0
sum3=0
for j in b:
if(j>0):
if(j%2==0):
sum1=sum1+j
else:
sum2=sum2+j
else:
sum3=sum3+j
print("Sum of all positive even numbers:",sum1)
print("Sum of all positive odd numbers:",sum2)
print("Sum of all negative numbers:",sum3)
24
OUTPUT:
Case 1:
Enter the number of elements to be in the list:4
Element: -12
Element: 34
Element: 35
Element: 89
Sum of all positive even numbers: 34
Sum of all positive odd numbers: 124
Sum of all negative numbers: -12
Case 2:
Enter the number of elements to be in the list:5
Element: -45
Element: -23
Element: 56
Element: 23
Element: 7
Sum of all positive even numbers: 56
Sum of all positive odd numbers: 30
Sum of all negative numbers: -68
RESULT:
Thus, the program to find sum of negative numbers, positive even numbers and
positive odd numbers in a list in python was written and executed successfully.
25
AIM:
To write a python program to perform addition of two square matrices
ALGORITHM:
PROGRAM:
r=int(input("enter rows"))
c=int(input("enter columns"))
a=[]
for i in range(r):
t=[]
for j in range(c):
val=int(input(f"enter a[{i}[{j}]:"))
t.append(val)
a.append(t)
b=[]
for i in range(r):
t=[]
for j in range(c):
val=int(input(f"enter b[{i}[{j}]:"))
t.append(val)
b.append(t)
sum=[]
for i in range(r):
t=[]
for j in range(c):
val=a[i][j]+b[i][j]
t.append(val)
sum.append(t)
print(a)
print(b)
print(sum)
27
OUTPUT:
enter rows 3
enter columns 3
enter a[0[0]:1
enter a[0[1]:1
enter a[0[2]:1
enter a[1[0]:2
enter a[1[1]:2
enter a[1[2]:2
enter a[2[0]:3
enter a[2[1]:3
enter a[2[2]:3
enter b[0[0]:4
enter b[0[1]:4
enter b[0[2]:4
enter b[1[0]:5
enter b[1[1]:5
enter b[1[2]:5
enter b[2[0]:1
enter b[2[1]:1
enter b[2[2]:1
[[1, 1, 1], [2, 2, 2], [3, 3, 3]]
[[4, 4, 4], [5, 5, 5], [1, 1, 1]]
[[5, 5, 5], [7, 7, 7], [4, 4, 4]]
RESULT:
Thus, the program to perform addition of two square matrices in python was
written and executed successfully.
28
AIM:
To write a python program to perform multiplication of two square matrices
ALGORITHM:
Step 1: Start the program
Step 2: Get the number of rows and columns for matrix 1 and matrix 2 from the
user
Step 3: Check if matrix 1 and matrix 2 are compatible for multiplication (if the
number of columns in matrix 1 is equal to the number of rows in
matrix 2)
Step 4: If they are compatible, initialize a zero matrix for the result
Step 5: Get input for each element of matrix 1 and matrix 2 from the user
Step 6: Perform matrix multiplication on matrix 1 and matrix 2 and store the
result in the zero matrix
Step 7: Print the resulting matrix
Step 8: If matrix 1 and matrix 2 are not compatible, print an error message
Step 9: Stop the program
29
PROGRAM:
a = int(input("Enter the no of rows for Matrix 1: "))
m=0
n=0
print("\n")
print("-----------Enter the values for Matrix 1-------------")
for i in range(a):
tem = []
for j in range(b):
m = int(input("Enter the value {0} for matrix 1:".format(n + 1)))
tem.append(m)
n=n+1
mat1.append(tem)
30
print("\n\n")
print("------------Enter the values for Matrix 2-----------------")
n=0
for i in range(a1):
tem = []
for j in range(b1):
m = int(input("Enter the value {0} for matrix 2:".format(n + 1)))
tem.append(m)
n=n+1
mat2.append(tem)
print("Matrix-------->2")
for r in mat2:
print(r)
for j in range(len(mat2[0])):
for k in range(len(mat2)):
ans[i][j] += mat1[i][k] * mat2[k][j]
else:
print("\n")
print("UNABLE TO DO MATRIX MULTIPLICATION")
31
OUTPUT:
[1, 2, 3]
[4, 5, 6]
32
Matrix-------->2
[1, 2]
[3, 4]
[5, 6]
---------------------------Result Matrix-------------------------
[22, 28]
[49, 64]
RESULT:
Thus, the program to perform multiplication of two square matrices in python
was written and executed successfully.
33
AIM:
To write a python program to find the factorial of a number using recursion
ALGORITHM:
PROGRAM:
def fact(n):
if n == 0:
return 1
else:
return n*fact(n-1) #function calling itself
OUTPUT:
Enter the number : 4
The factorial of 4 is 24
RESULT:
Thus, the program to find the factorial of a number using recursion in python
was written and executed successfully.
36
AIM:
ALGORITHM:
PROGRAM:
class RomanConverter:
def __init__(self):
self.num_to_sym_map = {
1: "I",
4: "IV",
5: "V",
9: "IX",
10: "X",
40: "XL",
50: "L",
90: "XC",
100: "C",
400: "CD",
500: "D",
900: "CM",
1000: "M"
}
self.sorted_nums = sorted(self.num_to_sym_map.keys(), reverse=True)
converter = RomanConverter()
print(converter.convert(int(input("Please enter a number: "))))
38
OUTPUT 1:
Please enter a number: 35
XXXV
OUTPUT 2:
Please enter a number: 994
CMXCIV
OUTPUT 3:
Please enter a number: 1995
MCMXCV
OUTPUT 4:
Please enter a number: 2015
MMXV
OUTPUT 5:
Please enter a number: 2242
MMCCXLII
RESULT:
Thus, the program to Convert an integer to roman numeral using class in
python was written and executed successfully.
39
AIM:
ALGORITHM:
Single Inheritance
Step 1: Start the program
Step 2: Define a parent class with a method to display a message
Step 3: Define a child class that inherits from the parent class and has a method
to display a different message
Step 4: Create an instance of the child class
Step 5: Call the method in the child class to display the message
Step 6: Call the method in the parent class to display the message
Step 7: Stop the program
Multilevel Inheritance
Step 1: Start the program
Step 2: Define a grandparent class with a method to display a message
Step 3: Define a parent class that inherits from the grandparent class and has a
method to display a different message
Step 4: Define a child class that inherits from the parent class and has a method
to display a different message
Step 5: Create an instance of the child class
Step 6: Call the method in the grandparent class to display the message
Step 7: Call the method in the parent class to display the message
Step 8: Call the method in the child class to display the message
Step 9: Stop the program
40
PROGRAM:
# Single Inheritance
class parent:
def display(self):
print("PARENT")
class child(parent):
def show(self):
print("CHILD")
c1 = child()
c1.show()
c1.display()
PROGRAM:
# Multi-level Inheritance
class grandparent:
def gdisplay(self):
print("GRAND PARENT")
class parent(grandparent):
def pdisplay(self):
print("PARENT")
class child(parent):
def cdisplay(self):
print("CHILD")
c1 = child()
c1.gdisplay()
c1.pdisplay()
c1.cdisplay()
41
OUTPUT:
E:\pythonProject1>python singleinheritance.py
CHILD
PARENT
OUTPUT:
E:\pythonProject1>python multi-inheritance.py
GRAND PARENT
PARENT
CHILD
RESULT:
Thus, the program to perform single Inheritance and Multi Inheritance to
perform polymorphism in python was written and executed successfully.
42
AIM:
ALGORITHM:
PROGRAM:
# polymorphism.py
class dog:
def sound(self):
print("bow bow")
class cat:
def sound(self):
print("meow")
def makesound(animaltype):
animaltype.sound()
catobj = cat()
dogobj = dog()
makesound(catobj)
makesound(dogobj)
44
OUTPUT:
E:\pythonProject1\polymorphism.py
meow
bow bow
RESULT:
Thus, the program to perform polymorphism in python was written and
executed successfully.
45
AIM:
ALGORITHM:
PROGRAM:
# maths_tools.py
def fibonacci(n):
n1=0
n2=1
print(n1)
print(n2)
for x in range(0,n):
n3 = n1 + n2
if n3 >= n:
break
print(n3,end = '\n')
n1=n2
n2=n3
using_fibonacci.py
OUTPUT:
Enter range: 10
FIBONACCI SERIES
0
1
1
2
3
5
8
RESULT:
Thus, the program to define a module and import a specific function in that
module to another program in python was written and executed successfully.
48
AIM:
ALGORITHM:
PROGRAM:
# Basic calculator
def sum():
a = int(input("Enter 1st No:"))
b = int(input("Enter 2nd No:"))
return a + b
def div():
a = int(input("Enter 1st No:"))
b = int(input("Enter 2nd No:"))
return a / b
def mul():
a = int(input("Enter 1st No:"))
b = int(input("Enter 2nd No:"))
return a * b
def sub():
a = int(input("Enter 1st No:"))
b = int(input("Enter 2nd No:"))
return a - b
print("Enter 1(sum)/2(div)/3(mul)/4(sub)")
i = int(input("Choice :"))
if i == 1:
print(sum())
elif i == 2:
print(div())
elif i == 3:
print(mul())
elif i == 4:
print(sub())
else:
print("Wrong Choice")
50
OUTPUT:
Enter 1(sum)/2(div)/3(mul)/4(sub)
Choice :4
Enter 1st No:5
Enter 2nd No:3
2
RESULT:
Thus, the program to create a simple calculator using function in python was
written and executed successfully.
51
AIM:
ALGORITHM:
PROGRAM:
import turtle
import time
screen=turtle.Screen()
trtl=turtle.Turtle()
screen.setup(420,320)
screen.bgcolor('black')
clr=['red','green','blue','yellow','purple']
trtl.pensize(4)
trtl.penup()
trtl.setpos(-90,30)
trtl.pendown()
for i in range(5):
trtl.pencolor(clr[i])
trtl.forward(200)
trtl.right(144)
turtle.mainloop()
53
OUTPUT:
RESULT:
Thus, the program to draw star using turtle in python was written and executed
successfully.
54
Date :
AIM:
ALGORITHM:
PROGRAM:
import turtle
loadWindow = turtle.Screen()
turtle.speed(0)
turtle.color("red")
turtle.pensize(3)
for i in range(45):
turtle.circle(5*i)
turtle.circle(-5*i)
turtle.left(i)
turtle.exitonclick()
56
OUTPUT:
RESULT:
Thus, the program to draw Spiral Helix Pattern using turtle in python was
written and executed successfully.
57
AIM:
ALGORITHM:
Step 1: Start the program
Step 2: Import the turtle module
Step 3: Create a list of colors to be used for the turtle's pen
Step 4: Set up the screen with a specific background color
Step 5: Create a turtle object and set its speed
Step 6: Begin a loop to draw the shapes
Step 7: Set the pen color for the current iteration of the loop using the modulo
operator
Step 8: Set the pen width for the current iteration of the loop
Step 9: Move the turtle forward a certain distance based on the current iteration
of the loop
Step 10: Turn the turtle left by a certain angle for each iteration of the loop
Step 11: Repeat the loop for the desired number of iterations
Step 12: Keep the screen open until the user closes it
Step 13: Stop the program
58
PROGRAM:
import turtle
colors= ['red','purple','blue','green','orange','yellow',]
t= turtle.Pen()
turtle.bgcolor('black')
t.speed(50)
for x in range(200):
t.pencolor(colors[x%6])
t.width(x/100+1)
t.forward(x)
t.left(59)
turtle.mainloop()
59
OUTPUT:
RESULT:
Thus, the program to draw Rainbow Benzene using Turtle in Python was
written and executed successfully.
60
AIM:
ALGORITHM:
PROGRAM:
import turtle
import time
screen=turtle.Screen()
trtl=turtle.Turtle()
screen.setup(976,553)
screen.bgpic('bg.png')
trtl.shape('turtle')
trtl.color('red','black')
s=20
trtl.penup()
trtl.setpos(30,30)
for i in range(28):
s=s+2
trtl.stamp()
trtl.forward(s)
trtl.right(25)
time.sleep(0.25)
turtle.mainloop()
62
OUTPUT:
RESULT:
Thus, the program to design footprint using turtle in python was written and
executed successfully.
63
AIM:
ALGORITHM:
PROGRAM:
functions_with_turtle.py
import turtle
# Move the turtle and draw another square with a size of 150 pixels
t.penup()
t.forward(150)
t.pendown()
draw_square(t, 150, "red", 10)
65
OUTPUT:
RESULT:
Thus, the turtle program was created using functions in python and executed
successfully.
66
AIM:
ALGORITHM:
PROGRAM:
tkinder.py
import tkinter as tk
filemenu.add_command(label="Save", command=save_text)
OUTPUT:
RESULT:
Thus, the program to design a text editor using python tk was written and
executed successfully.
69
AIM:
ALGORITHM:
PROGRAM:
append_remove_list.py
my_list = []
# add some elements to the list
my_list.append(1)
my_list.append(2)
my_list.append(3)
my_list.append(4)
OUTPUT:
[1, 2, 3, 4]
[2, 3, 4]
RESULT:
Thus, the program to create, append and remove lists in python was written and
executed successfully.
72
Ex. No. 13.b TEST WHETHER TWO STRINGS ARE NEARLY EQUAL
Date :
AIM:
PROGRAM:
string_comparision.py
# calculate the similarity ratio as the number of matching characters divided by the
length of the longer string
similarity = matching_chars / max_length
OUTPUT 1:
Enter first string : Bharath University
Enter second string : Computer Science
The strings are not nearly equal
OUTPUT 2:
Enter first string : Bharath University
Enter second string : Bharath Uni
The strings are nearly equal
RESULT:
Thus, the program to test whether two strings are nearly equal was written
and executed successfully.
75
Ex. No. 14.a FIND ALL DUPLICATES AND UNIQUE IN THE LIST
Date :
AIM:
To write a python program to find all duplicates and unique elements in a list.
ALGORITHM:
PROGRAM:
list_unique_and_duplicates.py
# split the user input by spaces and add the numbers to the list
numbers = user_input.split()
OUTPUT:
RESULT:
Thus, the program to write a python program to find all duplicates and unique
elements in a list was written and executed successfully.
78
Ex. No. 14.b FIND MEAN, MEDIAN, MODE FOR THE GIVEN SET OF
NUMBERS IN A LIST
Date :
AIM:
To write a python program to find the mean, median and mode of a list.
ALGORITHM:
PROGRAM:
Mean_median_mode.py
import statistics
mean = statistics.mean(numbers)
median = statistics.median(numbers)
mode = statistics.mode(numbers)
print("Mean:", mean)
print("Median:", median)
print("Mode:", mode)
80
OUTPUT:
RESULT:
Thus, the program to find mean, median, mode for the given set of numbers in
a list Was written and executed successfully.
81
AIM:
ALGORITHM:
Step 1: Start the program
Step 2: Import the sys module
Step 3: Print the first command line argument passed to the program
Step 4: If the first command line argument is 'set', create a set with values 1, 2, 3, 4,
and 5
Step 5: Print the values in the set
Step 6: Get input from the user for a number to add to the set and add it to the set
Step 7: Get input from the user for a number to remove from the set and remove it
from the set and print values in the set
Step 8: If the first command line argument is 'tuple', create a tuple with the days of
the week
Step 9: Print the tuple and its length
Step 10: Get input from the user for the index of an element in the tuple and print the
element
Step 11: If the first command line argument is not 'set' or 'tuple', print an error
message
Step 12: Stop the program
82
PROGRAM:
cmd_set_tuples.py
import sys
if sys.argv[1] == 'set':
numbers = {1, 2, 3, 4, 5}
print("The values in set are : ", numbers)
print(my_tuple)
print("Length of the tuple is ", len(my_tuple))
else:
print('Invalid command line argument')
83
OUTPUT:
RESULT:
Thus, the program to demonstrate working with set, tuples and command line
arguments was written and executed successfully.
84
AIM:
To write a program to Count the numbers of characters in the string and store
them in a dictionary data structure
ALGORITHM:
PROGRAM:
dict={}
word = input("Enter the String : ")
for i in word:
if i in dict:
dict[i] += 1
else:
dict[i] = 1
print ("{characters:count}")
OUTPUT:
RESULT:
Thus, the program to count characters in a string and store in dictionary was
written and executed successfully.
87
AIM:
To write a program to print each line of a file in reverse order.
ALGORITHM:
PROGRAM:
OUTPUT:
RESULT:
Thus, the program to print each line of a file in reverse order was written and
executed successfully.
90
Ex. No. 17.b PRINT ALL OF THE UNIQUE WORDS IN THE TEXT
FILE IN ALPHABETICAL ORDER
Date :
AIM:
To write a python program to print all of the unique words in the text file in
alphabetical order.
ALGORITHM:
PROGRAM:
uniq = []
words = []
for i in file:
words = words + i.split()
print("The Contents of the file : ")
for word in words:
print(word, end=" ") words.sort()
for j in words:
if j in uniq:
continue
else:
uniq.append(j)
OUTPUT:
RESULT:
Thus, the program to print all of the unique words in the text file in
alphabetical order was written and executed successfully.
93
AIM:
To write a python program to compute the number of characters, words and
lines in a text file.
ALGORITHM:
PROGRAM:
no_of_words = 0
no_of_lines = 0
no_of_chars = 0
for l in file:
no_of_lines += 1
no_of_words += len(l.split())
no_of_chars += len(l)
OUTPUT:
Enter the file name : count.txt
Lines : 14
Words : 704
Characters : 4413
RESULT:
Thus, the program to compute the number of characters, words and lines in a
text file was written and executed successfully.
96
AIM:
ALGORITHM:
PROGRAM:
count = 0
for l in file:
words = l.split()
for i in words:
for j in i:
if j == letter:
count += 1
print(count)
98
OUTPUT:
Enter the file name : letter.txt
Enter the letter : g
6
RESULT:
Thus, the program to count the occurrences of a letter in a text file was written
and executed successfully.
99
AIM:
To write a python program to design file to take the contents of the first file
should be input and written to the second file.
ALGORITHM:
PROGRAM:
file2con.close()
file2lines = file2con.readlines()
print(file2lines)
101
OUTPUT:
RESULT:
Thus, the program to take the contents of the first file and write to the second
file was written and executed successfully.
102
AIM :
To write a python program to demonstrate Exception Handling.
ALGORITHM:
PROGRAM:
try:
a = int(input("Enter a : "))
b = int(input("Enter b :))
c = a/b
print(a, "/", b, " = ", c)
except ZeroDivisionError:
print("Can't divide by zero..")
except ValueError:
print("Numbers Only!!")
OUTPUT 1:
Enter a :
23Enter
b:0
Can't divide by zero..
Exception Handling Works Correctly!!
OUTPUT 2:
Enter a : 23
Enter b : adv
Numbers
Only!!
Exception Handling Works Correctly!!
RESULT:
Thus, the program to demonstrate Exception Handling was written and
executed successfully.