Open
Conversation
|
Hello León:) Te dejo algunas cosillas pero buen lab en general!! Poco a poco la cosa va cogiendo ritmo:) Felicidades 💥
sqrt = list(map(lambda x: math.sqrt(x), range(1,101)))
sqrtTe pide la raíz cuadrada los 100 primeros números, en tu rango especificas
divisible_by_seven = [x for x in range(1,1001) if x%7 == 0]
print(divisible_by_seven)Te pide los números divisibles entre 7 de 1-1000, en tu rango especificas
vowels = "aeiouAEIOU"
non_vowels = [i for i in teststring if i.lower() 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'.
path = "../../lectures" -- your path here:)
files = [os.listdir(path)]
from os import listdir
filenames = [f for f in listdir(path)]
print(filenames)
random_lists = [[random.randrange(n,101) for n in range(0,10)] for i in range(0,5)]
print(random_lists)Te dejo una manera de solucionarlo:) Tu approach no es del todo correcto.
for i in ['a','b','c']:
try:
print (i**2)
except:
print(f"I cannot square the element of your list {i}")Te dejo el BONUS también:
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()
results = list(set([num for div in range(2,10) for num in range(1,1001) if num%div == 0]))
print(results)
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! 💥 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

No description provided.