Last active
June 9, 2018 22:42
-
-
Save stevencombs/6197227 to your computer and use it in GitHub Desktop.
This code is the solution to the Codecademy Python Function Syntax Assignment: Practice Makes Perfect.
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
# Cube a number if divisible by three with no remainder | |
# A Codecademy Python assignment | |
# Dr. Steven B. Combs, coding novice | |
def cube(n): | |
"""Cube a number""" | |
n = n ** 3 # Cube the number | |
print n # Print the number | |
return n # Return | |
def by_three(n): | |
"""Is number divisible by 3""" | |
if n % 3 == 0: # Verify number is divisible by 3 | |
return cube(n) # If divisible by 3, pass number to function 'cube' | |
else: | |
print "Not divisible by 3" # Print | |
return False # Return false value | |
# CODE EXECUTION BEGINS BELOW # | |
number = input("Number: ") # Request number from user | |
by_three(number) # Pass number of function 'by_three' |
Thanks!Helpful!
Thanks for Sharing, this was very Helpful.
just wondering when did you changed the number variable for n ??
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks! This was very helpful!