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 trialvbqlkxxmbb
5,030 PointsCreate a function named square. It should define a single parameter named number. In the body of the function, return
I got stuck with this one can somebody help me resolve this, And if i could get brief explanation where is mistake.
import math
def square(number):
return(square)
number = int(input("what is the number")
square = ("number**2")
print(square)
2 Answers
boi
14,242 PointsThe challenge asks you to do two things;
1st) You have to create a function named square which takes one parameter;
def square(number):
2nd) The challenge wants you to take the "number" parameter, multiply it with itself and return the value;
def square(number):
return number * number
Any number that multiplies with itself is called "square" of a number, and that is exactly what the challenge wants you to do, multiply the number by itself. That's it, If you still have some issues let me know.
Steven Parker
231,268 PointsHere's a few hints:
- the name of the function is "square", you don't want to return this
- the parameter is "number", you should return this multiplied by itself
- you won't need to include "math" for this
- for task 1 you won't need to "input" or "print" anything, just define the function
Steven Parker
231,268 PointsIf you show your current code, I'll be happy to help identify the syntax error.