Personal tools
 
Document Actions

The solutions

The solutions for the exercises on the previous page.

Se

This tutorial will demonstrate in an entertaining way how to start programming. The tutorial shows how to program Tux Droid with a simple but powerful language: Python.
Page 6 of 6.

Exercise 1:

  • Make the robot rotate two times to the left.
>>> tux.cmd.spinl_on(8,5)

Exercise 2:

  • Make tux Droid blink the eyes 6 times.
>>> tux.cmd.eyes_on(12)

Exercise 3:

  • First open and then close the beak.
>>> tux.cmd.mouth_open()
>>> tux.cmd.mouth_close()

Exercise 4:

  • Make Tux Droid say something in English with a female voice.
>>> tux.tts.select_voice_us_female()
>>> tux.tts.speak('Hello there !')


Exercise 5:

  • Let Tux Droid count with the voice synthesis from 0 to 9.
>>> for number in range(10):
... tux.tts.speak(number)
>>>

Exercise 6:

Let Tux Droid count from 0 to 9 like in the above exercise. But this time he needs to say more than just the numbers. For every number Tux needs to say: "The number is ", followed by the number. And if the number is 5 he has to say: "The magic number is " followed by the number.
>>> for number in range(10):
... if number == 5:
... tux.tts.speak(’The magic number is %d’ % number)
... else :
... tux.tts.speak(’The number is %d’ % number)
>>>

 
by Se last modified 2007-08-02 20:21
You are here: Home Documentation Tutorials Programming Tux Droid with Python The solutions

Powered by Plone CMS, the Open Source Content Management System