Computer Science, asked by daleisipranjali, 6 months ago

Write a program in python to find the area and perimeter of a rectangle and

a square (program should take input from user i.e. length and breadth for rectangle and side for square).​

Answers

Answered by Anonymous
4

 {\boxed{\underline{\purple{\bf\tt{Program:} } }}}

l= float(input("Enter the length:"))

b=float(input("Enter the breadth:"))

unit= str(input("Enter unit:")) #i.e cm, m etc

pm= 2*(l+b)

area= l*b

if l==b:

 \: \: \: \: print("The shape is a square")

 \: \: \: \: print("The perimeter of square is", pm, unit,"and the area is", area,"square", unit)

else:

 \: \: \: \: print("The shape is a rectangle")

 \: \: \: \: print("The perimeter of the rectangle is", pm,unit,"and the area is", area,"square",unit)

 {\boxed{\underline{\orange{\bf\tt{Output :} } }}}

Enter the length: 5

Enter the breadth:6

Enter unit: cm

The shape is a rectangle

The perimeter of the rectangle is 22.0 cm and area is 30.0 square cm

Answered by parijaini
2

l= float(input("Enter the length:"))</p><p></p><p>b=float(input("Enter the breadth:"))</p><p></p><p>unit= str(input("Enter unit:")) #i.e cm, m etc</p><p></p><p>pm= 2*(l+b)</p><p></p><p>area= l*b</p><p></p><p>if l==b:</p><p></p><p>\: \: \: \: print("The shape is a square")</p><p></p><p>\: \: \: \: print("The perimeter of square is", pm, unit,"and the area is", area,"square", unit)</p><p></p><p>else:</p><p></p><p>\: \: \: \: print("The shape is a rectangle")</p><p></p><p>\: \: \: \: print("The perimeter of the rectangle is", pm,unit,"and the area is", area,"square",unit)</p><p></p><p>{\boxed{\underline{\orange{\bf\tt{Output :} } }}}Output:</p><p></p><p>Enter the length: 5</p><p></p><p>Enter the breadth:6</p><p></p><p>Enter unit: cm</p><p></p><p>The shape is a rectangle</p><p></p><p>The perimeter of the rectangle is 22.0 cm and area is 30.0 square cm</p><p></p><p>

Similar questions