Professional Documents
Culture Documents
Artificial Intelligence: Lab Journal# 4
Artificial Intelligence: Lab Journal# 4
ARTIFICIAL INTELLIGENCE
LAB JOURNAL# 4
BAHRIA UNIVERSITY
ISLAMABAD CAMPUS
1
AI LAB JOURNAL # 4
LAB JOURNAL # 4
INTRODUCTION:
To get known of the basics of python that includes classes, objects, inheritance.
OBJECTIVE:
Introduce the basics of python.
Code in python.
Submission Date
2
AI LAB JOURNAL # 4
LAB TASKS
LAB TASK 1
SOLUTION
Code
import math
print("Name:- Shujahat Abbasi ")
print("Enrollment:- 01-131182-052 ")
print("Calculating the Area of :")
print("Circle ")
print("Square ")
print("Cylinder ")
print("Rectangle")
def CalculateArea(ShapeName):
ShapeName = ShapeName.lower()
if ShapeName == "rectangle":
l = int(input("Enter rectangle length: "))
b = int(input("Enter rectangle breadth: "))
RectangleArea = l * b
print(f"Area of rectangle is {RectangleArea}.")
elif ShapeName == "circle":
pi = 3.14
r = int(input("Enter circle radius: "))
CircleArea = pi * r * r
print(f"Area of circle is {CircleArea}.")
elif ShapeName == "square":
s = int(input("Enter square length: "))
SquareArea = s * s
print(f"Area of square is {SquareArea}.")
3
AI LAB JOURNAL # 4
elif ShapeName == 'cylinder':
r = int(input("Enter cylinder's radius: "))
h = int(input("Enter cylinder's height: "))
CylinderArea =2*math.pi*pow(r,2)*h
print(f"Area of cylinder is {CylinderArea}.")
else:
print("Sorry Shape not available")
# driver code
if __name__ == "__main__" :
Shapename = input("Enter the name of the shape ")
CalculateArea(Shapename)
OUTPUT
CONCLUSION:
We completed the tasks given to us and pasted output above.
THE END!