Skip to content

Instantly share code, notes, and snippets.

@Eclairemoy
Created July 18, 2019 21:38
Show Gist options
  • Save Eclairemoy/9cfcf53f23ccd9f24a98633744207846 to your computer and use it in GitHub Desktop.
Save Eclairemoy/9cfcf53f23ccd9f24a98633744207846 to your computer and use it in GitHub Desktop.
#CracklePop Program
def crackle_pop(n):
"""
a function that takes an integer n
calls check_if_divisible on every integer between 1-100 inclusive
prints the result
keyword arguments -- integer n
"""
if (n < 101):
result = check_if_divisible(n)
print(result)
crackle_pop(n+1)
def check_if_divisible(n):
"""
a function that takes an integer n
if number is divisible by 3 and 5 it prints "CracklePop"
if a number is divisible by 3 it prints "Crackle"
if a number is divisible by 5 it prints "Pop"
if a number is neither divisible by 3 nor 5 it prints the number
keyword arguments -- integer n
"""
crackle_pop_dict = {15: "CracklePop", 5: "Pop", 3: "Crackle"}
for k, v in crackle_pop_dict.items():
if n % k == 0:
n = v
break
return n
# Driver program
if __name__ == "__main__":
input = 1
crackle_pop(input)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment