Is the rectangle a square?

EasyIf-Else Programs · 51 of 64

Write a Python program that takes the length and breadth of a rectangle and checks whether it is a square.

Advertisement
Input
length 4, breadth 5
Output
Length: 4
Breadth: 5
It is not a square

Approach

  1. A rectangle is a square when length equals breadth.

Solution

Python
length = float(input("Length: "))breadth = float(input("Breadth: "))if length == breadth:    print("It is a square")else:    print("It is not a square")
Outputtyped input: 4, 5
Length: 4
Breadth: 5
It is not a square

Line by line

Lines 1-2

float() accepts decimal lengths too.

Learn the concept

New to this topic? Read the lesson, then come back.

More if-else programs

← All 64 If-Else Programs

Leave a Comment