Ejercicios: 3Eva_IT2009_T3 Aspirantes a escuela de policia
Propuesta de solución en Python: py_pdf, también con versión en matlab: m_pdf
# ICM00794-Fundamentos de Computación - FCNM-ESPOL # 3Eva_IT2009_T3 Aspirantes a escuela de policia # Propuesta de solucion: edelros@espol.edu.ec # Tarea: Desarrollar caso 3, Contar por genero import numpy as np # Tabla usada es aspirante aspirante = [] n = 0 opcion = 0 while not(opcion==5): print('1. Registra aspirante') print('2. Promedio de edad') print('3. Total por genero') print('4. Total por instruccion') print('5. Salir') opcion = int(input('cual opcion: ')) if (opcion==1): print(' Registra aspirante') texto = input(' nombre: ') numero = int(input(' edad: ')) gen = int(input(' genero [1,2]: ')) escolar = int(input('instruccion [1,3]: ')) candidato = {'nombre':texto, 'edad':numero, 'genero':gen, 'instruccion':escolar} aspirante.append(candidato) n = n + 1 if (opcion==2): print(' Promedio de edad') # n=len(aspirante) suma = 0 fila = 0 while not(fila>=n): suma = suma + aspirante[fila]['edad'] fila = fila + 1 promedio = suma/n print(promedio) if (opcion==3): print(' Total por genero') # TAREA: Contar por genero if (opcion==4): print(' Total por instruccion') # No se usará la fila 0 de veces veces = np.zeros(3+1,dtype=int) fila = 0 while (fila<n): k = aspirante[fila]['instruccion'] veces[k] = veces[k]+1 fila = fila + 1 # Salida print(' primaria: '+str(veces[1])) print(' segundaria: '+str(veces[2])) print(' superior: '+str(veces[3])) if (opcion==5): print(' gracias por usar el software ') if (opcion<1 or opcion>5): print(' *** NO ES OPCION DISPONIBLE ***')