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 trialToheeb Ashorobi
1,782 PointsI do not understand the question.
I am not too sure if what I am doing is incorrect. Assuming that the question is asking for the square root of a number I used 25. I imported the math function "sqrt" to give me a square root of the "number".
1) I do not know how to print a script in this case without writing words to show the calculation (I hope that makes sense)
2) As I ran the script it says that the "math" word is not defined?
Im not too sure what is going on.
import math
def square(number):
return math.sqrt (number)
ans = square(25)
print("the answer is {}".format(ans))
1 Answer
andren
28,558 PointsThe questions is in fact not asking for the square root of the number, but for the square. Despite the similar names those are different mathematical concepts. The square of a number is essentially just the number multiplied with itself. So the square of 25 would be 625 (25 * 25) for example.
Also for these challenges you are best of not doing anything beyond the exact thing you are asked for. Since the first task only asks you to define the function you don't have to run the function or print it out. Doing anything beyond what is asked will often confuse the code checker.
So for the first task of this challenge you simply need to define a function that returns the number passed into it multiplied with itself. Like this:
def square(number):
return number * number
Toheeb Ashorobi
1,782 PointsToheeb Ashorobi
1,782 PointsThank you very much Andren! I was definitely overthinking the question.