Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

What is my mistake in this program?

0 votes
asked Oct 25, 2022 by Ameen Muhammad (120 points)
num = 1
eval(input("Enter length and width"))
if width/length == num:
   print("It is a square")
else:
    print("It is a rectangle")

2 Answers

0 votes
answered Oct 29, 2022 by RAKSHIT GARG (140 points)
width=int(input("Enter width"))
length=int(input("Enter length"))
if width == length:
   print("It is a square")
else:
    print("It is a rectangle")

use this instead...
+1 vote
answered Oct 30, 2022 by Peter Minarik (86,180 points)

The eval() function evaluates a string, as it would be a Python instruction. I don't see why you'd need to have it here.

You did not declare your width and length variables, they do not exist, and they do not have any value assigned to them.

Your program would run if the code would be something like this:

length = int(input("Length? "))
width = int(input("Width? "))
if width == length:
   print("It is a square")
else:
    print("It is a rectangle")
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...