Python Programming for Raspberry Pi, Sams Teach Yourself in 24 Hours

(singke) #1

do not have to retype an entire script into your favorite text editor to modify it for your own needs.


Summary


In this hour, you learned how to create three Python projects: one that displays HD images to a
presentation screen, one that plays music from a music playlist, and one that combines the two scripts
into a special presentation.


Before you start thinking of all the modifications you can make to these projects, get ready. In the next
hour, you are about to learn some really cool and rather advanced projects using Python on the
Raspberry Pi!


Q&A


Q. What is Wayland, and could it help speed up the HD image presentation script?
A. Wayland is a replacement under-the-hood program that is partially responsible for displaying
windows in the GUI. It is promised to eventually be used in Raspbian. Will it speed up the HD
image presentation script? Possibly.
Q. Where is the Raspberry capital of the world?
A. The Raspberry capital of the world is Hopkins, Minnesota. The city hosts an annual raspberry
festival. The festival concerns fruit, and not computers.

Workshop


Quiz


1. You must use images that are already appropriately sized for the display screen. True or false?
2. What is the minimum resolution for an HD image?
3. Which PyGame operation handles the playing of music?
a. .pygame.music
b. .pygame.music.play
c. .pygame.mixer.music.play

Answers


1. False. When using the PyGame library, you can transform an image to an appropriate size.
However, if you increase the size of an image, you might lose the image’s original clarity.
2. An image is considered to be HD if it has at least a resolution of 1280×720 pixels.
3. Answer c is correct. The pygame.mixer.music.play operation handles the playing of a
loaded music file.
Free download pdf