Last active
August 16, 2023 14:13
-
-
Save qmmr/bdbaa8406afca5c48de59e86a43a7702 to your computer and use it in GitHub Desktop.
Homework Assignment #3: "If" Statements
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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 |
What do you need clarification with exactly?
<!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
.MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
-->I was doing an assignment on pirple.com which was similar and I then tried running the code in my python 3.9 on VS code and it failed to run it was giving a syntax error . despite that I just did what the assignment told me to do and I submitted and it was approved. Hence am not sure if its python version 3.9 which has a problem, I need some advice on how I can proceed Sent from Mail for Windows 10 From: GreasyGeeseSent: Wednesday, December 30, 2020 2:07 PMTo: qmmrCc: anamunda; CommentSubject: Re: qmmr/main.py @GreasyGeese commented on this gist.What do you need clarification with exactly?—You are receiving this because you commented.Reply to this email directly, view it on GitHub, or unsubscribe.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i really need some clarification on this one