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 trialJesse Busby
966 PointsI need help on regards to the following code challange.
The first one requires that I figure out how to square it. I can't either because math is not defined or that you can't use (number ^ 2), and I do not know why.
import math
number = input("number plz.. ")
def square(number):
return math.sqrt(int(number))
new_number = square(number)
print(new_number)
2 Answers
Steven Parker
231,096 PointsAn easy way to square a number is to multiply it by itself. For example:
square_of_num = num * num
Jesse Busby
966 PointsThank you all, this has been holding me back a few days!
And all I had to change was 2 Characters?!?
Steven Parker
231,096 PointsI find the most common errors (at least my own) are caused by a single character.
Shane Kimble
2,420 PointsShane Kimble
2,420 PointsI prefer exponentiation syntax (**) to square numbers:
squared_number = number**2
Steven Parker
231,096 PointsSteven Parker
231,096 PointsGood point, the ^ symbol is not used in Python for exponentiation but ** is.