Area of a square


#1

can anyone help me with the basic script in python to find the area of a square?


#2

that shouldn't be to tricky? You need to multiply the width and height of the square, what is the catch?

Can you show what code you have so far?


#3

.But in a square it's side,right?So i tried taking in the input for side.This is the code i tried.Dont know if its accurate.

to find the area of a square

side=float(input("Please enter the value for side"))

calculate area

area=side**2
print ("area of the square")


#4

print ("area of the square: {:d}".format(area))

seems to be fine? You just need to print the output


#5

Thank you!why do we use curly braces and format(area)?


#6

https://pyformat.info/

because format is great to use to combine variable and strings. It gives us much options and flexibility.


#7

Thank you for your advice!!