def primos(): # Esto no ha terminado! cola1 = Cola() for i in range(0, 10): cola1.arribo(randint(1, 10)) for i in range(0, cola1.tamanio()): aux = cola1.atencion() if (aux % 2 == 0 and aux % 3 == 0 and aux % 5 == 0 and aux % 7 == 0): cola1.arribo(aux) else: print(aux) print(" ") for i in range(0, cola1.tamanio()): print(cola1.atencion())
def invertir_pila(A): # 5 P = pila() C = Cola() for i in range(0, len(A)): print(A[i]) P.apilar(A[i]) while not P.pila_vacia(): C.arribo(P.desapilar()) for i in range(0, C.tamanio()): aux = C.atencion() print(aux) P.apilar(aux)
def vocales(word): # 1 palabra, vocales = Cola(), Cola() for i in range(0, len(word)): element = (word[i:i + 1]) palabra.arribo(element) for i in range(0, palabra.tamanio()): word = palabra.atencion() if (word == "a" or word == "e" or word == "i" or word == "o" or word == "u"): vocales.arribo(word) else: palabra.arribo(word)
def invertir(palabra): # 2 lacola = Cola() lapila = pila() print('la palabra es: ' + palabra) for i in range(0, len(palabra)): lacola.arribo(palabra[i:i + 1]) for i in range(0, lacola.tamanio()): lapila.apilar(lacola.atencion()) lapila.barrido_pila() for i in range(0, lapila.tamanio()): aux = lapila.desapilar() lacola.arribo(aux)