Anderson Pozo

Generation

generate functionThu, 22 Jun 2023

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

def par_primo(list): for number in list: # check if number is even if number % 2 == 0: print(number) break # check if number is prime else: for number in list: i = 2 while i < number: if number % i == 0: break else: print(number) break i = i + 1 break return list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] par_primo(list)

Questions about programming?Chat with your personal AI assistant