Anderson Pozo

Generation

generate functionTue, 20 Jun 2023

Dada una lista de 10 números enteros. Calcular e informar el primer número par, el primer número primo.

def checkEven(list): for i in list: if i%2 == 0: return i return None def checkPrime(list): for i in list: prime = True for j in range(2, i-1): if i % j == 0: prime = False break if prime: return i return None list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] print(checkEven(list)) print(checkPrime(list))

Questions about programming?Chat with your personal AI assistant