Welcome folks today in this blog post we will be calculating
area of square using python. All the full source code of application is shown below.
In order to get started you need to make an
app.py file and copy paste the following code.
First of all we will be computing the area of the
class square(): def __init__(self,length): self.length = length def areaofsquare(self): return (self.length*self.length) length=int(input("Enter length of Sqaure")) obj = square(length) print("Area of square:",obj.areaofsquare())
Now we will be using the
function method to calculate the
area of sqaure
def areaofsquare(length): return (length*length) length=int(input("Enter length of Sqaure")) print("Area of square:",areaofsquare(length))
Now if you execute the
python script by typing the below command