Confundido con las converciones | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

Confundido con las converciones

estremadamente confundido con la conversiónes

14th Apr 2017, 5:18 PM
Jose Ricardo
Jose Ricardo - avatar
8 ответов
+ 3
english?
14th Apr 2017, 5:26 PM
Nihad TK
Nihad TK - avatar
+ 2
here '210'(a string) is multiplied by 2(a integer) so answer would be 210210 but we used float so the answer became 210210.0 example hi(a string) is multiplied by 3(a integer) answer is 'hihihi'
14th Apr 2017, 6:07 PM
Nihad TK
Nihad TK - avatar
+ 1
I do not understand the conversations in the example. Neither the 210 * 2, the answer is not 420? Why is the 210210.0 response ????
14th Apr 2017, 5:32 PM
Jose Ricardo
Jose Ricardo - avatar
+ 1
210 is a int but "210" is a str
14th Apr 2017, 6:37 PM
Nihad TK
Nihad TK - avatar
+ 1
@jose yes
14th Apr 2017, 6:46 PM
Nihad TK
Nihad TK - avatar
+ 1
Si por ejemplo, haces un programa que multiplique un número por otro que diga el usuario, necesitarás recoger el otro número usando input. Hasta ahí todo bien. Pero después, cuando lo multipliques, te va a dar error, ya que input registra el número como una string. Por eso necesitas convertirlo a int antes de multiplicar con el otro int para que funcione. Y si en lo que tienes dudas es en qué hace cada cosa, aquí dejo una lista: int (integrer)-->un número entero: 1, 2, 3, 4, 5, 6, 7, ... infinito str (string)-->una palabra, aunque contenga números. El caso es que un string es registrado como texto: "hola", "tengo 3 gatos", "etc." float (floats)--> Esto es igual que integrers, solo que en este tipo de variables también te registra los números decimales. Es útil cuando quieres obtener resultados exactos: 7/3, 3.14, 7.0... etc. Y esto es lo básico, espero que así lo entiendas Por cierto, soy español, así que comentame cualquier cosa si lo necesitas ;)
17th Apr 2017, 7:58 AM
Ángel Daniel
Ángel Daniel - avatar
0
Since it is a (a string) and not?
14th Apr 2017, 6:14 PM
Jose Ricardo
Jose Ricardo - avatar
0
Ahhh everything is in the "", so the quotation marks are the ones that define whether or not it is string, am I correct?
14th Apr 2017, 6:45 PM
Jose Ricardo
Jose Ricardo - avatar