A Robotic Fairy Tale

A long, long time ago... in a faraway land ...
Are you brave enough to accept the challenge of writing function definitions that will make the following story come to life, and reproduce the final scene illustrated below?
Hint: my solution requires only five Python keywords: def, while, for, in, and global. You can do it of course without using some of these keywords, but your program will be longer.

# A robotic fairy tale
# Your definitions go here.

'''A long time ago, in RobotLand, lived a
young Robot Scholar, named Alex.'''
Alex = RefurbishedRobot(1, 1, beepers=2, colour='blue')

'''Unhappy, the young Scholar was spending his days 
wandering around his parents' domain, hoping to find more to learn.'''
Alex.set_trace_style(2, 'black')    # unhappy

'''Soon, the young Scholar set out to explore
the world, travelling far and wide. Even as he started out,
his mood brightened considerably.'''
Alex.set_trace_style(1, 'blue') 

'''One day, as he entered a foreign land,
the young Scholar heard an unusual noise that made him stop.
His heart did the same when a fearless Warrior, 
named Anna, appeared seemingly out of nowhere.
She had come investigate news that 
a stranger had come to her land.'''
Anna = RefurbishedRobot(4, 7, 's', colour='purple')
Anna.set_trace_style(2, 'red')

'''The Scholar knew that his quest was over; 
no further did he need to search.  Approaching
the Warrior, he took out the one and only Ring, 
which he happened to carry, 
and asked Anna if she would marry him.'''

'''The Scholar's erudite use of magical words
were such that, much to Alex's delight, Anna
took the Ring he had offered her.'''
# Historical note: the imprint of the Ring
# can still be seen in RobotLand where Alex proposed to Anna,
# as shown below.
# It has also been confirmed that, from that day, 
# Anna always wore her Ring.

'''The young couple celebrated their happiness,
and danced all day and all night.'''

'''Years went by.  Alex and Anna were happy
traveling together, side by side.'''

'''A few years later, young Alexina was born.'''

'''For many years afterwards, the happy family
pursued their travels to the edge of Robotland.'''

'''The End.'''

Fairy tale, final scene

For further reading

At this point in your Python learning journey, you might be ready to read other, more advanced material. Here are two suggestions:


Any resemblance between RobotLand's Scholar Alex and the Warrior Anna, and any real-life individuals is purely coincidental.

../images/SourceForge.net Logo