Squaring Numbers with PYTHON


#1

**What's wrong with this code to square numbers? **
Please help me.


num = raw_input()
nuevo_num = num**2
def alcuadrado(nuevo_num):
print nuevo_num
if num.isalpha():
print "Escribe un número, no puedes escribir letras" 
else:
print nuevo_num


#2

Should be the top line. Don't print anything inside the function, Just do the calculation (assume the correct input) and return it.

def alcuadrado(nuevo_num):
    return nuevo_num ** 2

num = raw_input("Escribe un número: ")
print (alcuadrado(num))

#3

I try it with a runner code and it doesnt work. It says the problem is in line 4.


#4

Please post a link to the lesson. Thanks.