Skip to content

Instantly share code, notes, and snippets.

@qmmr
Last active August 16, 2023 14:13
Show Gist options
  • Save qmmr/bdbaa8406afca5c48de59e86a43a7702 to your computer and use it in GitHub Desktop.
Save qmmr/bdbaa8406afca5c48de59e86a43a7702 to your computer and use it in GitHub Desktop.
Homework Assignment #3: "If" Statements
"""
pirple.com/python
Homework Assignment #3: "If" Statements
If conditionals.
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.
Bonus:
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 compare(a, b, c):
if int(a) == int(b) or int(a) == int(c) or int(b) == int(c):
return True
else:
return False
# Check the compare function
print(compare(1,1,2)) # True
print(compare(1,2,2)) # True
print(compare(1,2,1)) # True
print(compare(1,2,3)) # False
# Bonus
print(compare(6,5,"5")) # True
@anamunda
Copy link

i really need some clarification on this one

@GreasyGeese
Copy link

What do you need clarification with exactly?

@anamunda
Copy link

anamunda commented Dec 30, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment