Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Basics Functions and Looping Create a Function

create a function called square

squaring.py
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

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 68,457 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!