0

AI practice with error

I start the AI practice ask me to define this correctly: height = print( *2) I complete this height = input() print(heigth*2) And score me correct! ??? But is not correct inputs are strings and 2 is a number and is not possible multiple strings with number... at least a the very beginning of the course.

27th Apr 2023, 3:53 PM
Alejandro Rodríguez
3 Respostas
+ 4
First of all at the print line you have written heigth and not height… Second, you CAN multiply strings with number in python. Examples: “Hi” * 3: “HiHiHi” print(“hello\n” * 100) # prints 100 times “hello” in the console. Do you understand?
27th Apr 2023, 4:10 PM
Ugulberto Sánchez
Ugulberto Sánchez - avatar
+ 3
Te lo digo en español: Has puesto heigth y no height en la línea del print. Eso conllevará un error. Segundo, sí que puedes multiplicar strings por un número en python. Ejemplos: “Hola!” * 3 devuelve “Hola!Hola!Hola!” Otro ejemplo: “Que tal?\n” * 2 devuelve: Que tal? Que tal? Recuerda que \n es un caracter de escape que se usa para producir una nueva línea. print(“hello\n” * 100) devuelve 100 líneas en las que pone “hello”. Espero que esto te ayude ;)
27th Apr 2023, 4:15 PM
Ugulberto Sánchez
Ugulberto Sánchez - avatar
+ 3
I failed to comprehend your message. Nonetheless, it is imperative that you transform the string input into a numeric data type, either by invoking the int() or float() functions, prior to engaging in any mathematical manipulations.
27th Apr 2023, 5:21 PM
Sadaam Linux
Sadaam Linux - avatar