EL/LAK - Python Course

worksheet 04

You can find information about Pygame Draw commands here

In many of the following questions it is better to open the pygame basic template write and test the code.

  1. Explain how the computer coordinate system differs from the standard Cartesian coordinate system. There are two main differences. List both.
  2. Before a Python Pygame program can use any functions like pygame.display.set_mode(), what two lines of code must occur first?
  3. Explain how WHITE = (255, 255, 255) represents a color.
  4. When do we use variable names for colors in all upper-case, and when do we use variable names for colors in all lower-case? (This applies to all variables, not just colors.)
  5. What does the pygame.display.set_mode() function do?
  6. What does this for event in pygame.event.get() loop do?
  7. What is pygame.time.Clock used for?
  8. For this line of code:
    pygame.draw.rect(screen, GREEN, [10, 10, 100, 100], 5)
  9. What is the best way to repeat something over and over in a drawing?
  10. When drawing a rectangle, what happens if the specified line width is zero?
  11. Find information about pygame draw and describe the ellipse drawn in the code below.
    pygame.draw.ellipse(screen, RED, [20, 20, 250, 100], 2)
  12. Find information of drawing an arc. What additional information is needed over drawing an ellipse?
  13. Find information of drawing text and describe, in general, what are the three steps needed when printing text to the screen using graphics?
  14. When drawing text, the first line of the three lines needed to draw text should actually be outside the main program loop. It should only run once at the start of the program. Why is this? You may need to ask.
  15. Find information of drawing about drawing a polygon. What are the coordinates of the polygon that the code below draws?
    pygame.draw.polygon(screen, GREEN, [[50,100],[0,200],[200,200],[100,50]], 5)
  16. What does pygame.display.flip() do?
  17. What does pygame.quit() do?