Skip to content

Instantly share code, notes, and snippets.

@stevencombs
Last active December 20, 2015 21:19
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/6196788 to your computer and use it in GitHub Desktop.
Save stevencombs/6196788 to your computer and use it in GitHub Desktop.
A sample Python function that squares a number.
# Sample function code to square a number
# Identical to the sqrt function in the math module
# Dr. Steven B. Combs, coding novice
def square(n):
"""Returns the square of a number."""
squared = n**2
print "%d squared is %d." % (n, squared)
return squared
# Call the square function on line 9! Make sure to
# include the number 10 between the parentheses.
square (10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment