Python Python Basics Functions and Looping Create a Function

Eugen Paris
Eugen Paris
1,064 Points

create a function called square
import math

def square(number):
    return number square

Hi! in this challange u being asked to create a function named square that take a paramater, and return the square of the parameter u do it by multiply the parameter by it self. gl

Jamison Habermann
Jamison Habermann
11,690 Points

The challenge is asking you to create the function yourself, not use the math import.

You must create a function that creates a square of whatever number is passed in as an argument. A square of a number is the number multiplied by itself. Hope this helps.

1 Answer

Chris Freeman
Chris Freeman
Treehouse Moderator 59,735 Points

You are on the right path. There are a few simple ways to "square a number" in Python

# Let's set number to 5 
# to represent the argument passed to the function
>>> number = 5
>>> number * number  # A number times itself
>>> number ** 2  # A number raised to the power 2

Post back if you need more help. Good luck!