Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

AI LAB JOURNAL # 4

ARTIFICIAL INTELLIGENCE
LAB JOURNAL# 4

Name: Shujahat Mazhar Abbasi

Enrollment No: 01-131182-052

Lab Instructor: Sir Waleed

Date Submitted: April 30th, 2021

DEPARTMENT OF SOFTWARE ENGINEERING

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.

Evaluation: Signature of Lab Engineer:

Submission Date

April 30, 2021

2
AI LAB JOURNAL # 4

LAB TASKS

LAB TASK 1

Implement the calculate area function for:


rectangle,
square,
circle,
cylinder.

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!

You might also like