Skip to content

Patricia S. All donegit add main.ipynb#2

Open
psaeztorres wants to merge 1 commit intoIronhack-data-bcn-oct-2023:mainfrom
psaeztorres:main
Open

Patricia S. All donegit add main.ipynb#2
psaeztorres wants to merge 1 commit intoIronhack-data-bcn-oct-2023:mainfrom
psaeztorres:main

Conversation

@psaeztorres
Copy link
Copy Markdown

Enjoy this raining evening!! ;-)

@bripollc
Copy link
Copy Markdown

Hello Patricia:)

SUUUPER!!! Buen lab e hiciste el bonus, increíble:) Que gusto corregir labs así 💥 Te dejo un par de cosillas (sin importancia).

  • Calculate the square number of the first 20 numbers. Use square as the name of the list.
square = [i ** 2 for i in range(0,21)]
print(square)

Si quieres incluir el cuadrado de 20 en la lista, debes ajustar el rango a 21!

  • Calculate the square root of the first 100 numbers. Use sqrt as the name of the list.
sqrt=[i**2 for i in range(101)]
print(sqrt)

Idem que en el ejercicio anterior:) Si quieres incluir el cuadrado de 100 en la lista, debes ajustar el rango a 101!

  • Remove all of the vowels in a string. Hint: make a list of the non-vowels. Use non_vowels as the name of the list.
vowels = "aeiouAEIOU"
non_vowels = [i for i in teststring if i not in vowels and i != ' ']
print (non_vowels)

Tu código es OK!! Te dejo otra manera de hacerlo para que no tengas que importar el módulo de 'functools'.

  • Convert the numbers of the following nested list to floats. Use floats as the name of the list.
floats = [float(i) for sublist in list_of_lists for i in sublist]
print(floats)

Tu código es correcto!!!!! Solo quería dejarte otra manera de solucionarlo para tener el resultado en una lista "plana" que no contiene sublistas:)

  • Handle at least two kind of different exceptions when dividing a couple of numbers provided by the user.
try:
    x=int(input())
    y=int(input())
    z=x/y
    print(z)
except ZeroDivisionError as alias_1:
    print(f"upsss....carefull, it seems you have introduced a 0 as you're facing a {alias_1} error")
except TypeError as alias_2:
    print(f"take, care, one of the digits is a string and you have a {alias_2} error" )

Tu respuesta es super válida pero como te pide "numbers provided by the user" puedes usar el input() en lugar de una función.

Te dejo el BONUS 3:

 class NumSectionsError(Exception):
    pass
while True:
    try:
        Total_Marks = int(input("Enter Total Marks Scored: "))
        break
    except ValueError as error:
        print(error)
while True:
    try:
        Num_of_Sections = int(input("Enter Num of Sections: "))
        if Num_of_Sections > 2:
            raise NumSectionsError
        else:
            break
    except ValueError as error:
        print(error)
    except NumSectionsError:
        print("The number of sections can't be bigger than 2") 

A por el próximo laaaaaaab! 💥

image

@psaeztorres
Copy link
Copy Markdown
Author

psaeztorres commented Oct 17, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants