Main content
Course: Intro to computer science - Python > Unit 3
Lesson 1: Module importsChallenge: 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!