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 trialDelvin Roy
1,308 PointsPython Squaring Exercise : Create a function named square. It should define a single parameter named number.
In the body of the function, return the square of the value that was passed in.
I'm really stuck
import math
def square(number):
return (squared)
number= int(input("What is the number"))
squared = (number**2)
print(squared)
1 Answer
Steven Parker
231,248 PointsYou've got a calculation to create "squared", but it needs to be done inside the function (before "return").
Also, you won't need to "input" anything for this challenge.
Delvin Roy
1,308 PointsThank You! that helped
Coby Woods
202 PointsSteven Parker i know you already answered but i really do not understand can you break it down some more please?
Steven Parker
231,248 PointsCoby, it's just that all code in a function must be indented more than the "def" line. And since "return" ends the function, it must be the last thing done.
Delvin Roy
1,308 PointsDelvin Roy
1,308 PointsIt gives the right answer but I have no clue what to put on the return section. I've been at this for hours, no clue what to do.