Curso Python 3 desde cero

Поділитися
Вставка
  • Опубліковано 28 вер 2024

КОМЕНТАРІ • 24

  • @raquelleal6986
    @raquelleal6986 8 місяців тому +6

    Hola Ernesto, excelentes tus videos, me han ayudado muchísimo. Comparto mi solución para este ejercicio:
    dict_rom_inv ={1000:"M",900:"CM",500:"D",400:"CD",100:"C",90:"XC",50:"L",40:"XL",10:"X",9:"IX",5:"V",4:"IV",3:"III",2:"II",1:"I"}
    try:
    num = int(input("Ingresa un número entero para convertirlo a romano: "))
    if 1

  • @Angel-mq2ev
    @Angel-mq2ev 6 місяців тому +1

    Muchas gracias Ernesto!! Estos ejercicios prácticos y proyectos finales ayudan mucho a desarrollar la lógica de programación con lo que hemos ido aprendiendo a lo largo del curso.
    Contento de haber llegado en este caso a una solución muy similar a la tuya. Pongo a continuación la solución que había propuesto yo...
    romano = [("", "M", "MM", "MMM"),
    ("", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"),
    ("", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"),
    ("", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"),]
    try:
    entero = int(input("Ingresa un número entero para convertirlo a romano: "))
    if 0 < entero < 4000:
    millar = entero // 1000
    centena = entero % 1000 // 100
    decena = entero % 100 // 10
    unidad = entero % 10

    print(romano[0][millar] + romano[1][centena] + romano[2][decena] + romano[3][unidad])

    else:
    print("El número ingresado debe estar en un rango entre 1 y 3999")
    except ValueError:
    print("Debes ingresas un valor entero.")
    except Exception as e:
    print("Valor no válido: ", e)

  • @A_lone_programmer
    @A_lone_programmer 10 місяців тому +2

    Al final lo hice pero tuve que usar una parte de la alternativa que tú ofreciste, al parecer fue mal haber subestimado este proyecto, y yo decia que era fácil, pero aún así me gustó. ;'p ❤

  • @EDAN1351
    @EDAN1351 10 місяців тому +3

    se me cocino el cerebro pensando en todo para que el programa funcione y despues de ver el video me di cuenta que era una tonteria, aun asi les mando todo lo que hice para llegar al mismo resultado
    num = list(input("introduce un numero para pasar a romano: "))
    try:
    num = [int(i) for i in num]
    indice = int(len(num))
    roma = ""
    for n in num:
    if indice == 4:
    if n < 4:
    for i in range(1, n + 1):
    roma += "M"
    else:
    print("solo se permiten numeros de el 1 hasta el 3999")
    break
    elif indice == 3:
    if n < 4:
    for c in range(1, n + 1):
    roma += "C"
    elif n == 4:
    roma += "CD"
    elif n > 4 and n < 9:
    roma += "D"
    if n > 5:
    for d in range(6, n + 1):
    roma += "C"
    elif n == 9:
    roma += "CM"
    elif indice == 2:
    if n < 4:
    for dc in range(1, n + 1):
    roma += "X"
    elif n == 4:
    roma += "XL"
    elif n > 4 and n < 9:
    roma += "L"
    if n > 5:
    for dc in range(6, n + 1):
    roma += "X"
    elif n == 9:
    roma += "XC"
    elif indice == 1:
    if n < 4:
    for u in range(1, n + 1):
    roma += "I"
    elif n == 4:
    roma += "IV"
    elif n > 4 and n < 9:
    roma += "V"
    if n > 5:
    for u in range(6, n + 1):
    roma += "I"
    elif n == 9:
    roma += "IX"
    indice -= 1
    print(roma)
    except ValueError:
    print("solo se admiten numeros enteros")

    • @EDAN1351
      @EDAN1351 10 місяців тому +1

      me olvide copiar el ultimo except

  • @tomasfernandez3645
    @tomasfernandez3645 2 місяці тому

    Al principio se me ocurrio una forma parecida a la que tu hiciste, pero me parecio muy fácil, asi que lo cambio a uno un poco más complejo
    try:
    a = int(input("Ingrese un numero entero para convertirlo a romano: "))
    u = {1000: 'M', 500: 'D', 100: 'C', 50: 'L', 10: 'X', 5: 'V', 1: 'I', }
    nu = list(u.items())
    li = a
    resul = 0
    b = 0
    if a > 3999 or a < 1:
    print("el numero ingresado debe estar en un rango entre 1 y 3999")
    else:
    for i in range(len(nu)):
    if (li + 1) in u or (li + 10) in u or (li + 100) in u or b > 3:
    for o in range(len(nu) - 1, 0, -2):
    r = nu[o][1]
    if nu[o][0] < li and li < nu[o - 2][0]:
    for t in range(nu.index(nu[o]) - 2, nu.index(nu[o])):
    if nu[t][0] > li and nu[t + 1][0] < li:
    print(f"{r}{nu[t][1]}", end="")
    resul = nu[t][0] - nu[o][0]
    else:
    continue
    li = li - resul
    if li == 0:
    break
    b = int(li / nu[i][0])
    if b < 1 or b > 3:
    continue
    if li > 90 and li < 100:
    continue
    for e in range(b):
    print(nu[i][1], end="")
    li = li - (b * nu[i][0])
    except ValueError:
    print("debe ingresar un valor entero")

  • @HectorGonzales-be8bd
    @HectorGonzales-be8bd 10 місяців тому

    Buen video, como todos.

  • @kevinjulianvilamanrique5388
    @kevinjulianvilamanrique5388 9 місяців тому +1

    Ya lo hice. estuvo muy bueno, gracias. (Lo hace ver tan fácil :( )
    romanos = "MCXI"
    romanos_medio = "_DLV"
    valor = input("Ingresa un número entero para convertirlo a romano: ")
    equivalencia = ""
    try:
    if len(valor) < 4:
    for _ in range(4-len(valor)):
    valor = "0" + valor
    if int(valor) in range(1,4000):
    contador = -1
    for x in valor:
    if int(x) == 0:
    contador += 1
    continue
    elif int(x) in range(1,4):
    contador += 1
    p = romanos[contador]
    for _ in range(int(x)):
    equivalencia += p
    elif int(x) in range(4,9):
    contador += 1
    p = romanos[contador]
    m = romanos_medio[contador]
    if int(x) == 4:
    equivalencia += p
    equivalencia += m
    elif int(x) == 5:
    equivalencia += m
    else:
    equivalencia += m
    for _ in range(int(x)-5):
    equivalencia += p
    else:
    contador += 1
    p = romanos[contador]
    p1 = romanos[contador-1]
    print(equivalencia)
    else:
    print("El número ingresado debe de estar en unn rango entre 1 y 3999")
    except Exception:
    print("Debes de ingresar un valor entero")

  • @Nero01123
    @Nero01123 18 днів тому

    Yo logre solucionarlo, pasa que mi solucion supero las 1500 lineas de codigo jajajaja

  • @emmanuelbrayamjuradoyauri2481
    @emmanuelbrayamjuradoyauri2481 Місяць тому

    Me resulto dificil pero no me espera ese método que mostraste, aun asi mi idea era hacerlo compacto, les comparto haber que les parece
    num=input("Ingrese un numero entero: ")
    num=[int(char) for char in num]
    ro={1:"I",5:"V",10:"X",50:"L",100:"C",500:"D",1000:"M"}
    r=[0,5,10]
    for i in range(len(num)):
    for n in r:
    if num[i]==0:
    break
    if abs(num[i]-n)0:
    c3=(num[i]-n)*c2
    c1=c1+c3
    if num[i]-n

  • @miguelparedes1822
    @miguelparedes1822 6 місяців тому

    Mi solución:
    print("

    BIENVENIDO AL PROGRAMA QUE TRANSFORMA NÚMEROS ENTEROS EN NÚMEROS ROMANOS:

    ")
    salir = 0
    while salir == 0:

    try:
    print("Menu: ")
    opcion = int (input("
    '1'- Ingresar un número
    '2'- Finalizar el programa.
    \tSu opcion: "))
    except ValueError as ve:
    print("
    \tDebe ingresar un número entero.
    ")
    except Exception as e:
    print("
    \tDebe ingresar un número entero.
    ")
    else:
    if opcion ==1:

    try:
    num = int (input("Ingrese un numero entero entre 1 - 3999: "))
    except ValueError as ve:
    print("
    \tDebe ingresar un número entero.
    ")
    except Exception as e:
    print("
    \tDebe ingresar un número entero.
    ")
    else:
    if num < 1 or num>3999:
    print("
    \tIngrese un número entre 1 y 3999.
    ")
    else:
    unidades = {0: "",
    1: "I",
    2: "II",
    3: "III",
    4: "IV",
    5: "V",
    6: "VI",
    7: "VII",
    8: "VIII",
    9: "IX"}
    decenas = {0: "",
    10: "X",
    20: "XX",
    30: "XXX",
    40: "XL",
    50: "L",
    60: "LX",
    70: "LXX",
    80: "LXXX",
    90: "XC" }
    centenas = { 0: "",
    100: "C",
    200: "CC",
    300: "CCC",
    400: "CD",
    500: "D",
    600: "DC",
    700: "DCC",
    800: "DCCC",
    900: "CM"}
    milares = { 0: "",
    1000: "M",
    2000: "MM",
    3000: "MMM"}
    aux_milar = num % 1000
    milar = num - aux_milar
    aux_centena = aux_milar % 100
    centena = aux_milar - aux_centena
    aux_decena = aux_centena % 10
    decena = aux_centena - aux_decena
    unidad = aux_decena
    print(f"Equivalente a número romano: {milares[milar]}{centenas[centena]}{decenas[decena]}{unidades[unidad]}

    ")

    salir =0
    else:
    salir = 1
    print("

    Fin del programa.")

  • @luisdiegoseverino5676
    @luisdiegoseverino5676 9 місяців тому

    no entiendo porque dice unidades de millon si son millar; miles, no son millones.....

  • @HectorGonzales-be8bd
    @HectorGonzales-be8bd 10 місяців тому

    Es demacioda sinple haz algo mas dificil.

    • @End_lgo
      @End_lgo 10 місяців тому

      Pues graba tú тогда, блять😊

    • @LaGeekipediaDeErnesto
      @LaGeekipediaDeErnesto  10 місяців тому +2

      ¡Hola Héctor!, en el canal tengo una play list llamada clases en vivo donde resuelvo problemas de algoritmia.
      Ahí encontrarás ejercicios más avanzados donde podrás poner a prueba tus conocimientos intentado resolver los ejercicios propuestos en el lenguaje de programación Python.

  • @shelbysmith8498
    @shelbysmith8498 9 днів тому

    Lo siento profe pero me he importado un convertidor de números romanos xdd, esta es mi solucion.
    import roman
    while True:
    try:
    print("
    Convertidor Romano / normales:")
    print("Elige una de las dos opciones: ")
    print("1. Convertir de normales a romanos")
    print("2. Convertir de romanos a normales")
    print("3. Salir del programa")

    opcion_usuario = int(input("Introduce una opción: "))
    if opcion_usuario == 1:
    numero = int(input("Elige un numero que quieras tranformar a romano: "))
    numero_romano = roman.toRoman(numero)
    print(f"El número {numero} en romano es: {numero_romano}")
    elif opcion_usuario == 2:
    # Convertir de número romano a entero
    numero_romano = input("Ingrese un numero romano: ").upper()
    numero_entero = roman.fromRoman(numero_romano)
    print(f"El número romano {numero_romano} en entero es: {numero_entero}")
    elif opcion_usuario == 3:
    print("Gracias por usar el convertidor. ¡Hasta la próxima!")
    break
    else:
    print("Elige una de las dos opciones...")
    except Exception as e:
    print(f"Error {e} caracteres no validos")

  • @BrianHazel
    @BrianHazel 2 місяці тому

    try:
    numero = int(input("Ingresa un numero entero para convertir a romano: "))
    romano = ""
    if 0 < numero < 4000:
    numero = str(numero)
    serie = "123456789"
    longitud = len(numero)
    for ind, i in enumerate(numero):
    if i in serie:
    pos = longitud - ind
    if pos == 4:
    i = int(i)
    romano = "M" * i
    elif pos == 3:
    i = int(i)
    if i < 4:
    romano += "C" * i
    elif i == 4:
    romano += "CD"
    elif i == 5:
    romano += "D"
    elif 5 < i < 9:
    i = i - 5
    romano += "D" + "C" * i
    elif i == 9:
    romano += "CM"
    elif pos == 2:
    i = int(i)
    if i < 4:
    romano += "X" * i
    elif i == 4:
    romano += "XL"
    elif i == 5:
    romano += "L"
    elif 5 < i < 9:
    i = i - 5
    romano += "L" + "X" * i
    elif i == 9:
    romano += "XC"
    elif pos == 1:
    i = int(i)
    if i < 4:
    romano += "I" * i
    elif i == 4:
    romano += "IV"
    elif i == 5:
    romano += "V"
    elif 5 < i < 9:
    i = i - 5
    romano += "V" + "I" * i
    elif i == 9:
    romano += "IX"
    else:
    print("El número ingresado debe de estar en un rango entre 1 y 3999")
    print(romano)
    except Exception as error:
    print("Debes ingresar un numero entero. ", error)

  • @Juststudy-cc4ow
    @Juststudy-cc4ow 7 місяців тому

    Despues de 7 horas termine, sinceramente deberia practicar mas con las funciones matematicas de python,
    numerosRomanos = {1: "I",
    2: "II",
    3: "III",
    4: "IV",
    5: "V",
    9: "IX",
    10: "X",
    40: "XL",
    50: "L",
    90: "XC",
    100: "C",
    200: "CC",
    300: "CCC",
    400: "CD",
    500: "D",
    900: "CM",
    1000: "M",
    0: " "}
    s = 0
    try:
    a = int(input("Ingresa un numero para empezar la conversion "))
    b = str(a)
    c = a
    e = a
    if len(b) == 1:
    if a < 5:
    print(numerosRomanos[a])
    if a > 5 and a < 9:
    c -= 5
    print(numerosRomanos[5], numerosRomanos[c])
    if a == 9:
    print(numerosRomanos[c])
    if len(b) == 2:
    if a > 9 and a < 40:
    c //= 10
    e %= 10
    if c < 40:
    while s < c*10:
    s += 10
    print(numerosRomanos[10], end="")
    if e > 5 and e < 9:
    e -= 5
    print(numerosRomanos[5], numerosRomanos[e])
    else:
    print(numerosRomanos[e])
    if a > 39 and a < 50:
    c //= 10
    e %= 10
    print(numerosRomanos[c*10], end="")
    if e > 5 and e < 9:
    e -= 5
    print(numerosRomanos[5], numerosRomanos[e])
    else:
    print(numerosRomanos[e])
    if a >= 50 and a < 90:
    c -= 50
    c //= 10
    e %= 10
    print(numerosRomanos[50], end="")
    if a >= 60 and a < 90:
    while s < c*10 :
    s += 10
    print(numerosRomanos[10], end="")
    if e > 5 and e < 9:
    e -= 5
    print(numerosRomanos[5], numerosRomanos[e])
    else:
    print(numerosRomanos[e])
    if a >= 90 and a < 100:
    e -= 90
    print(numerosRomanos[90], end="")
    if e > 5 and e < 9:
    e -= 5
    print(numerosRomanos[5], numerosRomanos[e])
    else:
    print(numerosRomanos[e])
    if len(b) == 3:
    o = a
    q = c
    e %= 10
    c = o % 100
    c //= 10
    c = c * 10
    q -= c
    if q > 99 and q < 599:
    print(numerosRomanos[q], end= "")
    if q > 599 and q < 900:
    q -= 500
    print(numerosRomanos[500], numerosRomanos[q], end="")
    if q >= 900 and q < 1000:
    print(numerosRomanos[900], end="")
    if c > 9 and c < 40:
    s = 0
    while s < c:
    s += 10
    print(numerosRomanos[10], end="")
    if c == 40:
    print(numerosRomanos[c], end="")
    if c == 50:
    print(numerosRomanos[c], end="")
    if c > 50 and c < 90:
    print(numerosRomanos[50], end="")
    c -= 50
    s = 0
    while s < c:
    s += 10
    print(numerosRomanos[10], end="")
    if c == 90:
    print(numerosRomanos[c], end="")

    if e < 6:
    print(numerosRomanos[e])
    if e > 5 and e < 9:
    e -= 5
    print(numerosRomanos[5], numerosRomanos[e])
    if e == 9:
    print(numerosRomanos[e])


    if len(b) == 4:
    m = a
    o = a
    q = c
    e %= 10
    c = o % 100
    c //= 10
    c = c * 10
    q -= c
    ex = m % 1000
    q %= 1000
    q -= 5
    if m > 999 and m < 4000:
    m -= ex
    s = 0
    while s < m:
    s += 1000
    print(numerosRomanos[1000], end="")

    if q > 99 and q < 599:
    print(numerosRomanos[q], end="")
    if q > 599 and q < 899:
    print(numerosRomanos[500], end="")
    s = 0
    q -= 500
    while s < q:
    s += 100
    print(numerosRomanos[100], end="")
    if q == 900:
    print(numerosRomanos[900])

    if c > 9 and c < 40:
    s = 0
    while s < c:
    s += 10
    print(numerosRomanos[10], end="")
    if c == 40:
    print(numerosRomanos[c], end="")
    if c == 50:
    print(numerosRomanos[c], end="")
    if c > 59 and c < 90:
    print(numerosRomanos[50], end="")
    c -= 50
    s = 0
    while s < c:
    s += 10
    print(numerosRomanos[10], end="")
    if c == 90:
    print(numerosRomanos[c], end="")
    if e < 6:
    print(numerosRomanos[e], end="")
    if e > 5 and e < 9:
    print(numerosRomanos[5], end="")
    e -= 5
    print(numerosRomanos[e], end="")

    if a >= 4000:
    print("Lo sentimos no tenemos permitido mostrar mas numeros despued del 3999")
    except ValueError as VE:
    print("Ha sucedido un error en los valores", VE)

  • @juan_ortega23
    @juan_ortega23 4 місяці тому

    Aguante La Geekipedia De Ernesto, el mejor curso de Python en youtube. Saludos desde Argentina, gracias profe

  • @alejandrotorresvalverde4096
    @alejandrotorresvalverde4096 10 місяців тому

    Muchas gracias