Copyright © tutorialspoint.com
This function returns the sign of the difference of two numbers : -1 if x < y, 0 if x == y, or 1 if x > y
cmp( x, y ) |
Here is the detail of parameters:
x: This is a numeric expression.
y: This is also a numeric expression.
-1 if x < y, 0 if x == y, or 1 if x > y
#!/usr/bin/python print "cmp(80, 100) : ", cmp(80, 100) print "cmp(180, 100) : ", cmp(180, 100) print "cmp(-80, 100) : ", cmp(-80, 100) print "cmp(80, -100) : ", cmp(80, -100) |
This will produce following result:
cmp(80, 100) : -1 cmp(180, 100) : 1 cmp(-80, 100) : -1 cmp(80, -100) : 1 |
Copyright © tutorialspoint.com