Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Em: lab menys bonus, pero mira els missatges d'error :') #10

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

emmacunill
Copy link

No description provided.

@bripollc
Copy link

Hello Emma:)

Te dejo algunas cosillas pero buen lab en general!! Poco a poco la cosa va cogiendo ritmo:) Felicidades 💥

  • 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 = [math.sqrt(i) for i in range(0,101)]
print(sqrt)

Te pide la raíz cuadrada los 100 primeros números, en tu rango especificas range(0,20) 🫠 pequeño despiste jeje

  • Find all of the numbers from 1-1000 that are divisible by 7. Use divisible_by_seven as the name of the list.

Tu solución es correcta pero tal y como has especificado el range en otros casos no estarías incluyendo el 1000 en tu rango.

  • 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.lower() not in vowels and i != ' ']
print(non_vowels)

Te dejo un pequeño tip!!!! Si añades and i != ' ', también eliminarás los espacios en blanco y te quedarás únicamente son las consonantes.

  • Find all the consonants in the sentence 'The quick brown fox jumped over the lazy dog'.

Idem que en ejercicio anterior:) Puedes añadir and i != ' ' para eliminar los espacios en blanco.

Te dejo el BONUS también:

  • Bonus 1
 def square_cal():
    x = input("Insert an integer to square")
    integer=False
    while integer == False:
        try:
            x= int(x)
            integer == True
            return x**2
        except ValueError as error:
            x = input(f"{error}, please insert an valid integer to square")
square_cal()
  • Bonus 2
 results = list(set([num for div in range(2,10) for num in range(1,1001) if num%div == 0]))
print(results)
  • 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 ver chica, muy bien ehhhhhhhh 🌻🌻🌻🌻🌻
A por el siguiente laaaaaab!

image

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