## DEV Community is a community of 642,931 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

# How to make a game with python

I am web developer and data scientist

## simple game for kid

In maths class it will be more interesting if we have a kind of game that kids could play and still be learning from it. here I am going to show you how to write codes for multiplication game.
The nature of our game

1. we need the screen to display question and ask the kid to provide the answer
2. the question should be multiplication of two random number from 1 to 20
3. it should state if the kid get it right or wrong
4. repeat the question 10 times
5. print the kids scores. Now that we have known the nature we need to interpret it in code form.
• we need `randint()` to generate random number
• `input()` and `int()` for kid to provide answer
• for loop in range 10 to ask question 10times
• if function to check if answer right or wrong
• counter that keep the score record
• `print()` function to print out the result. Now let's code it.
``````from random import randint #to import the randint
mark=0
for i in range(10):
a=randint(1,20)#first number
b=randint(1,13)#second number
que=int(input('Question {}: {} x {} ='.format(i+1,a,b))) #format method to insert the question order
if que==a*b: #check if the answer is correct
print('Right!')
mark=mark+1 #counter