Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Basics Functions and Looping Create a Function

I'm stumped

I feel like I'm missing something basic here but just overlooking it, also do I always import math?

import math 

def square(number):
    number = (input("Enter a number:   "))
    return  (number*number) 

2 Answers

It depends on what part of the challenge you are on. If you are on the first part:

def square(number):
    return  (number*number) 

You only have to import math if you are going to use one of the functions in the math class (i.e. ceil, floor, or sqrt), not to perform simple arithmetic.

Hope this helps!

Simon Coates
Simon Coates
4,912 Points

I don't know python, but you seem to be trying to overwrite the parameter you're meant to use. For part 1, it seems to accept:

def square(number):
    return  number*number