Last active
February 9, 2021 01:30
-
-
Save carljavier/9e267e4767ee29774260fdfe567b986f to your computer and use it in GitHub Desktop.
Programming/Scriptin - Using your preferred programming or scripting language, write a function that takes a number as an argument and returns the string “aunty” if that number is divisible by 3 and returns “uncle” otherwise.
This file contains 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
import sys | |
# Assumes what is passed into function is integer, however prefer to type cast it to be sure. | |
def whoisit(index): | |
# Given that there are two scenarios where value could not be divisible by x could be 0 or any other number. | |
if (int(index) % 3 > 0) or (int(index) == 0) : | |
return "uncle" | |
else : | |
return "aunty" | |
print(whoisit(sys.argv[1])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Test via CLI
python whoisit.py 5