GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — PythonIBM/Ejercicio1_poo.py at master · 1975Pepe/PythonIBM Expand file tree/ Copy pathEjercicio1_poo.pyMore file actions 41 lines (32 loc) · 1.19 KB / Copy pathEjercicio1_poo.pyFile metadata and controls41 lines (32 loc) · 1.19 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 # Ejemplo de programación estructurada. # Definimos unos cuantos clientes clientes = [ {'Nombre': 'Hector', 'Apellidos': 'Costa Guzman', 'dni': '11111111A'}, {'Nombre': 'Juan', 'Apellidos': 'González Márquez', 'dni': '22222222B'} ] # Creamos una función que muestra un cliente en una lista a partir del DNI def mostrar_cliente(nombre, dni): for c in clientes: if (dni == c['dni']): print('{}{}'.format(c['Nombre'], c['Apellidos'])) return print('Cliente no encontrado') # Creamos una función que borra un cliente en una lista a partir del DNI def borrar_cliente(clientes, dni): for i, c in enumerate(clientes): if (dni == c['dni']): del (clientes[i]) print(str(c), "> BORRADO") return print('Cliente no encontrado') # Fíjate muy bien cómo se utiliza el código estructurado print("==LISTADO DE CLIENTES==") print(clientes) print("\n==MOSTRAR CLIENTES POR DNI==") mostrar_cliente(clientes, '11111111A') mostrar_cliente(clientes, '11111111Z') print("\n==BORRAR CLIENTES POR DNI==") borrar_cliente(clientes, '22222222V') borrar_cliente(clientes, '22222222B') print("\n==LISTADO DE CLIENTES==") print(clientes) |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |