GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — PythonIBM/Ejercicio1_poo.py at master · 1975Pepe/PythonIBM

Expand file tree

/

Ejercicio1_poo.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
41 lines (32 loc) · 1.19 KB
/

Ejercicio1_poo.py

Copy path

File metadata and controls

41 lines (32 loc) · 1.19 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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.