If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

Challenge: Avatar generator

Instructions

Step 1

Randomize the nose

Krista and Carmen programmed an avatar module to draw characters for their game. Instead of giving every player the same avatar, they want to randomly generate one at the start of the game.

  • Use random.randint() to generate a random number between 1 and 2, inclusive.
  • Use the random number to randomly draw either a triangle or button nose, where each shape is equally likely.

The avatar.draw_nose() function takes one of two possible nose shapes as an argument: "triangle" or "button". One of the numbers should mean you draw a triangle nose and the other number should mean you draw a button nose.

Remember to import the random module at the top of the program!

Code editor

Code files

Output