Skip to content

Instantly share code, notes, and snippets.

@stevencombs
Last active June 9, 2018 22:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevencombs/6197227 to your computer and use it in GitHub Desktop.
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.
# 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'
@joshharr
Copy link

Thanks! This was very helpful!

@xu3Seven
Copy link

Thanks!Helpful!

@jmcgrath207
Copy link

Thanks for Sharing, this was very Helpful.

@noel0010
Copy link

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