length = input()
area = pow(length,2)
print(area)
In this we can give an integer as well as a float number so how we can solve this problem?
length = input()
area = pow(length,2)
print(area)
In this we can give an integer as well as a float number so how we can solve this problem?
If your problem is 'how can I cast a str to the best numeric representation', try this:
x = input()
try:
x = int(x)
except ValueError:
x = float(x)
Here is the solution:
length = input().strip()
if "." in length:
length = float(length)
else:
length = int(length)
area = pow(length, 2)
print(area)