Python Python Basics Functions and Looping Create a Function

Eugen Paris
Eugen Paris
1,064 Points

create a function called square

squaring.py
import math

def square(number):
    return number square
<noob />
<noob />
16,316 Points

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,353 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
MOD
Chris Freeman
Treehouse Moderator 56,951 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
25
>>> number ** 2  # A number raised to the power 2
25

Post back if you need more help. Good luck!