External Exam Download Resources Web Applications Games Recycle Bin

Load a random coin image

random_coin.py

import pygame
pygame.init()
screen = pygame.display.set_mode((400, 300))
done = False

import random
number = random.randint(1,2)
if number == 1:
  coin = pygame.image.load("heads.gif")
else:
  coin = pygame.image.load("tails.gif")

while not done:
  for event in pygame.event.get():
    if event.type == pygame.QUIT:
      done = True
      
  screen.blit(coin, (100, 50))
  
  pygame.display.flip()
  
pygame.quit()

put image files + python file into same folder: