0% found this document useful (0 votes)
47 views4 pages

Artificial Intelligence: Lab Journal# 4

This document is lab journal #4 submitted by Shujahat Mazhar Abbasi. It details an assignment to calculate the areas of basic shapes like rectangles, squares, circles, and cylinders using Python code. The code implements functions to calculate the areas that take user input for dimensions. When run, the code outputs the calculated areas for each shape. The conclusion states the tasks were completed and outputs were shown as requested.

Uploaded by

ali khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views4 pages

Artificial Intelligence: Lab Journal# 4

This document is lab journal #4 submitted by Shujahat Mazhar Abbasi. It details an assignment to calculate the areas of basic shapes like rectangles, squares, circles, and cylinders using Python code. The code implements functions to calculate the areas that take user input for dimensions. When run, the code outputs the calculated areas for each shape. The conclusion states the tasks were completed and outputs were shown as requested.

Uploaded by

ali khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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