ex27.py modified