The 365 Data Science team is proud to invite you to our own community forum. A very well built system to support your queries, questions and give the chance to show your knowledge and help others in their path of becoming Data Science specialists.
Ask
Anybody can ask a question
Answer
Anybody can answer
Vote
The best answers are voted up and moderated by our team

Python Exercise – Notable built in functions

Python Exercise – Notable built in functions

Super Learner
0
Votes
1
Answer

I am using the following code. Everything works except for the part where I printing “Cat” and the program should give me an Output of “Not Possible” but it is giving an error. 
def distance_from_zero(x):
   if(type(x)== int() or type(x)==float()):
     return abs(x)
   else:
      print(“Not Possible”)

1 Answer

365 Team

Hi Archisman!
Thanks for reaching out.
Can you please support your question with the code you’ve executed, as well as with a screenshot containing the entire error message? Only then will we be able to provide a specific answer. Thank you.
Currently, I ran your code and then executed the function with an argument of “Cat”, and did indeed obtain “Not Possible” as an answer.

distance_from_zero("Cat")


Looking forward to your reply.
Hope this helps.
Best,
Martin

Thanks Martin! It works. I don’t know why it wasn’t working at that time

1 month

Hi Archisman! Great! Thank you for letting us know! Good luck and please feel free to post another question should you encounter any difficulties. Thank you.
Best,
Martin

4 weeks
×
Ready to Learn
Data Science?
50% OFF