-3

Question:- Create a function called square that takes in a number and returns the square of that number. If what's passed in is not a float or an int, return "None"

Code:-

def square(x):
    if x % 2 == 0:
        return x**x
    else:
        return None
print(square(5))

Error:-

None !- 25 : square should return 25

Your Output

None

1 Answers1

-1

why are you doing modulus 2 here?

def square(x):
   if isinstance(x,int) or isinstance(x,float):
     return x**2
   else:
     return none
print(square(5))
Makyen
  • 31,849
  • 12
  • 86
  • 121