Question

For Python: Write a function that receives 3 numbers as arguments and returns “1” if they...

For Python:

Write a function that receives 3 numbers as arguments and returns “1” if they are all the same, and "0" is they are all different. Otherwise, the function returns "-1".

0 0
Add a comment Improve this question Transcribed image text
Answer #1

CODE:

#function that accepts 3 numbers as parameters
def checkNums(a,b,c):
#if all three numbers are same function returns 1
if(a==b and b == c):
return 1
#if all three numbers are different function returns 0
elif(a != b and b != c and c!= a):
return 0
else:
#else returns -1
return -1

#calling the function
print(checkNums(23,23,23))
print(checkNums(1,2,3))
print(checkNums(1,2,2))

______________________________________________

CODE IMAGES AND OUTPUT:

In [9]: 4 5 6 8 1 #function that accepts 3 numbers as parameters 2 def checkNums(a,b,c): 3 #if all three numbers are same fun_____________________________________________

Feel free to ask any questions in the comments section
Thank You!

Add a comment
Know the answer?
Add Answer to:
For Python: Write a function that receives 3 numbers as arguments and returns “1” if they...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT