I want to share my code to everybody.
Create a function that accepts 3 parameters and checks for equality between any two of them.
Your function should return True if 2 or more of the parameters are equal, and false is none of them are equal to any of the others.
Modify your function so that strings can be compared to integers if they are equivalent. For example, if the following values are passed to your function:
6,5,“5”
You should modify it so that it returns true instead of false.
Hint: there’s a built in Python function called “int” that will help you convert strings to Integers.
def function_num_comparison(x, y):
if x >= y:
print(x, "is greater than or equal to", y)
elif y <= x:
print(x, "is less than or equal to", x)
elif x > y:
print(x, "is greater than", y)
elif y < x:
print(y, "is less than", x)
elif y > x:
print(y, "is greater than", x)
elif x < y:
print(x, "is less than", y)
else:
print("Error")
print(function_num_comparison(3.5,8))
def function_rock_paper_scissors_comparison(rock_paper_scissors_first_user, rock_paper_scissors_second_user, rock_paper_scissors_third_user):
if rock_paper_scissors_first_user == "rock" and rock_paper_scissors_second_user == "paper" and rock_paper_scissors_third_user == "scissors":
if len(rock_paper_scissors_second_user*2) > len(rock_paper_scissors_first_user):
print(rock_paper_scissors_second_user, "beats", rock_paper_scissors_first_user)
print(True)
print("___________________")
if len(rock_paper_scissors_first_user*2) > len(rock_paper_scissors_third_user):
print(rock_paper_scissors_first_user, "beats", rock_paper_scissors_third_user)
print(True)
print("_____________________")
if len(rock_paper_scissors_third_user*2) > len(rock_paper_scissors_second_user):
print(rock_paper_scissors_third_user, "beats", rock_paper_scissors_second_user)
print(True)
print("______________________")
elif rock_paper_scissors_first_user == "paper" and rock_paper_scissors_second_user == "rock" and rock_paper_scissors_third_user == "scissors":
if len(rock_paper_scissors_first_user*2) > len(rock_paper_scissors_second_user):
print(rock_paper_scissors_first_user, "beats", rock_paper_scissors_second_user)
print(True)
print("___________________")
if len(rock_paper_scissors_second_user*2) > len(rock_paper_scissors_third_user):
print(rock_paper_scissors_second_user, "beats", rock_paper_scissors_third_user)
if len(rock_paper_scissors_third_user*2) > len(rock_paper_scissors_first_user):
print(rock_paper_scissors_third_user, "beats", rock_paper_scissors_first_user)
print(True)
print("___________________")
elif rock_paper_scissors_first_user == "scissors" and rock_paper_scissors_second_user == "paper" and rock_paper_scissors_third_user == "rock":
if len(rock_paper_scissors_first_user*2) > len(rock_paper_scissors_second_user):
print(rock_paper_scissors_first_user, "beats", rock_paper_scissors_third_user)
print(True)
print("___________________")
if len(rock_paper_scissors_third_user*2) > len(rock_paper_scissors_first_user):
print(rock_paper_scissors_third_user, "beats", rock_paper_scissors_first_user)
if len(rock_paper_scissors_second_user*2) > len(rock_paper_scissors_third_user):
print(rock_paper_scissors_second_user, "beats", rock_paper_scissors_third_user)
print(True)
print("___________________")
elif rock_paper_scissors_first_user == "paper" and rock_paper_scissors_second_user == "scissors" and rock_paper_scissors_third_user == "rock":
if len(rock_paper_scissors_first_user*2) > len(rock_paper_scissors_third_user):
print(rock_paper_scissors_first_user, "beats", rock_paper_scissors_third_user)
print(True)
print("___________________")
if len(rock_paper_scissors_second_user*2) > len(rock_paper_scissors_first_user):
print(rock_paper_scissors_second_user, "beats", rock_paper_scissors_first_user)
print(True)
print("___________________")
if len(rock_paper_scissors_third_user*2) > len(rcok_paper_scissors_second_user):
print(rock_paper_scissors_third_user, "beats", rock_paper_scissors_second_user)
print(True)
print("___________________")
if len(rock_paper_scissors_third_user*2) > len(rock_paper_scissors_second_user):
print(rock_paper_scissors_third_user, "beats", rock_paper_scissors_second_user)
print(True)
print("___________________")
print()
function_rock_paper_scissors_comparison("paper", "rock", "scissors")
def number_comparison_function(a, b, c):
if a > b:
print(a, "is greater than", c)
print(True)
print()
elif a > b:
print(a, "is not greater than", b)
print(False)
print()
if b > a:
print(b, "is greater than", a)
print(True)
print()
elif b > a:
print(b, "is not greater than", a)
print(False)
print()
if c > a:
print(c, "is greater than", a)
print(True)
print()
elif c > a:
print(c, "is not greater than", a)
print(False)
print()
if c > b:
print(c, "is greater than", b)
print(True)
print()
elif c > int(b):
print(c, "is not greater than", b)
print(False)
print()
if a < b:
print(a, "is less than", b)
print(True)
print()
elif a < int(b):
print(a, "is not less than", int(b))
print(False)
print()
if float(b) < a:
print(float(b), "is less than", a)
print(True)
print()
elif float(b) < a:
print(float(b), "is not less than", a)
print(False)
print()
if c < a:
print(c, "is less than", a)
print(True)
print()
elif c < a:
print(c, "is not less than", a)
print(False)
print()
if c < int(b) and int(b) < c:
print(c, "is less than", int(b) ,"and ", int(b), "is less than", c)
print(True)
elif c < b:
print(c, "is not less than", b)
print(False)
print()
if a == int(b):
print(a, "is equal to", int(b))
print(True)
elif float(b) == a and float(a) == int(a):
print(b, "is not equal to", a)
print(False)
print()
if a == c:
print(a, "is equal to", c)
print(True)
print()
elif c == a:
print(c, "is not equal to", a)
print(False)
print()
if b == c:
print(b, "is equal to", c)
print(True)
print()
elif c == b and 2.912 == float(b):
print(c, "is not equal to", float(b) ,"and", 2.912, " is not equal to", float(b))
print(False)
number_comparison_function(1.582, 5.9242 , 3.2191392)
print()