Ejemplo n.º 1
0
from lab01 import Registry

race = Registry()
race.addRunner({'name': 'Gerhard', 'email': '*****@*****.**', 'speed': '<40'})
race.addRunner({'name': 'Tom', 'email': '*****@*****.**', 'speed': '<30'})
race.addRunner({'name': 'Toni', 'email': '*****@*****.**', 'speed': '<20'})
race.addRunner({'name': 'Margot', 'email': '*****@*****.**', 'speed': '<30' })
race.addRunner({'name': 'Gerhard', 'email': '*****@*****.**', 'speed': '<30'})


runners = race.getRunnersInCategory('<30')

s = ''
for idx, val in enumerate(runners, start=1):
    s += "runner {}: {} \n".format(idx, val['name'])
print(s)
Ejemplo n.º 2
0
from lab01 import Registry

race = Registry()
race.addRunner({
    'name': 'Gerhard',
    'email': '*****@*****.**',
    'speed': '<40'
})
race.addRunner({'name': 'Tom', 'email': '*****@*****.**', 'speed': '<30'})
race.addRunner({'name': 'Toni', 'email': '*****@*****.**', 'speed': '<20'})
race.addRunner({'name': 'Margot', 'email': '*****@*****.**', 'speed': '<30'})
race.addRunner({
    'name': 'Gerhard',
    'email': '*****@*****.**',
    'speed': '<30'
})

runners = race.getRunnersInCategory('<30')

s = ''
for idx, val in enumerate(runners, start=1):
    s += "runner {}: {} \n".format(idx, val['name'])
print(s)
Ejemplo n.º 3
0
from lab01 import Registry

registry = Registry()
registry.addRunner({'email': '*****@*****.**', 'speed': '<40'})
registry.addRunner({'email': '*****@*****.**', 'speed': '<30'})
registry.addRunner({'email': '*****@*****.**', 'speed': '<30'})
print(registry.getCategory())
# ['<20', '<30', '<40', '>40']
print(registry.getRunnersInCategory('<30'))
# [{'email': '*****@*****.**', 'speed': 23}, {'email': '*****@*****.**', 'speed': 27}]
print(registry.getSpeedByEmail('*****@*****.**'))
# <30
print(registry)

registry1 = Registry()
registry1.addRunner({'email': '*****@*****.**', 'speed': '<40'})
registry2 = Registry()
registry2.addRunner({'email': '*****@*****.**', 'speed': '<30'})
registry3 = Registry()
registry3.addRunner({'email': '*****@*****.**', 'speed': '<40'})
print(registry1 == registry2)
# false
print(registry1 == registry3)
# true