Computer Science, asked by PATRIOTS4966, 17 days ago

write a method to that takes to char agruments and returns 0 if the both arguments are equal and the method returns -1 if the first argument is smaller than the second and one is the second argument is smaller than the first

Answers

Answered by Equestriadash
6

The following co‎des have been written using Python.

\tt d ef\ check\_equality(x,\ y):\\{\ \ \ \ \ }if\ x\ ==\ y:\\{\ \ \ \ \ }{\ \ \ \ \ }print(0)\\{\ \ \ \ \ }elif\ x\ >\ y:\\{\ \ \ \ \ }{\ \ \ \ \ }print(-1)\\{\ \ \ \ \ }elif\ x\ <\ y:\\{\ \ \ \ \ }{\ \ \ \ \ }print(1)

We can create functions using \tt d ef in Python. Here, we've created a function called \tt check\_equality() that takes two arguments. Using conditional statements, we check if the arguments are equivalent. If they are, 0 is printed. If the first argument is greater than the second, -1 is printed and if the first argument is lesser than the second, 1 is printed. We check for their relationship using relational operators, ==, > and <.

Similar questions