Area and Perimeter of square
you are given a side of square as input.Write a program to find the perimeter and area of square.
input
the input is an integer representing the length of the side of the square
output
the first line of the output should contain area of the square, and the second line of the output should contain the perimeter of the square as per the format shown in the sample output.
explanation
given the length of the side is 2 .
as the area of square is side*side and perimeter of the square is 4*side
the output should be
area of the square is : 4
perimeter of the square is : 8
sample input 1
3
sample output 1
area of the square is : 9
perimeter of the square is : 12
sample input 2
4
sample output 2
area of the square is : 16
perimeter of the square is : 16
def area_per(l):
return 'The area and perimeter of the square is given by {} and {}'.format(l ** 2, 4 * l)
area_per(2)
'The area and perimeter of the square is given by 4 and 8'
Comments
Leave a comment