¡GoConqr estrena diseño! Cuéntanos qué te parece.

Módulo 3 de 13 · Texto

The input() function - prohibited operations

David Khieu

The input() function - prohibited operations

Look at the code in the editor. run it, enter any number, and press Enter. 

What happens? 

Python should give you the following output: 

Traceback (most recent call last):
File ".main.py", line 4, in <module>
something = anything ** 2.0
TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'float'

The last line of the sentence explains everything - you tried to apply the ** operator to 'str' (string) accompanied with 'float'

This is prohibited. 

This should be obvious - can you predict the value of "to be or not to be" raised to the power of 2? 

We can't. Python can't either. 

Have we fallen into a deadlock? Is there a solution to this issue? Of course there is. 

 

Instrucciones

Para avanzar en el curso, envía un intento de este test. Puedes enviarlo después de la última pregunta.

Ir al módulo elegido

Escríbenos

¿Sobre qué es tu mensaje?

¿Qué te parece el nuevo diseño?

¿Te gusta?