๐Ÿ
B.TECH I YEAR โ€ข II SEMESTER โ€ข R25

Python Programming - Lab Manual

Python Programming Laboratory โ€ข Program Solution

๐Ÿ“˜ R25 Regulation ๐ŸŽ“ I Year ๐Ÿ“š II Semester ๐Ÿ Python Programming ๐Ÿงช Lab Program
Selected Program

geometrical shapes and operations

โ† All Python Programs

Aim:

☛   Use the structure of exception handling all general-purpose exceptions.

Solution :


PROGRAM: (exception_handling.py)

 
def function(a,b):
	c = a / b
	print ( c )
try :
	a = int(input(" Enter a value : "))
	b = int(input(" Enter b value : "))
	function(a,b)
except ValueError :
	print(" Value Error Occurred \t Pease Enter Correct integer Values ")
except ZeroDivisionError :
	print(" Zero Division Error Occurred \t Can't division by zero ")
else :
	print(" Successfully executed without errors ")


OUTPUT:

 
Sample Run 1:
 Enter a value : 5
 Enter b value : 0
 Zero Division Error Occurred    Can't division by zero

Sample Run 2:
 Enter a value : 5
 Enter b value : 3
1.6666666666666667
 Successfully executed without errors

Sample Run 3:
 Enter a value : 5
 Enter b value : d
 Value Error Occurred    Pease Enter Correct integer Values



๐Ÿ’ป Run This Python Program

geometrical shapes and operations
The selected Python program is loaded automatically into the editor. Edit the program, provide input if required and click Run.

The compiler is embedded using OneCompiler. Your Python program runs inside the embedded Python environment; Study Glance does not execute Python code directly on your web server.
โ† Back to Python Lab Programs ๐Ÿ“š All Lab Manuals