# Welcome to my basic games!

We have learnt to code with python

### Game 1

This is the python code using pygame zero:

``````
# playa is a sprite, that is, a moving image in a game
# Playa is the name of a Class sprite (Alicia is an example of the class Homo sapiens), this means create an object from a class
# 'playa' is a name of a image in the folder images
playa = Actor('playa')
# topright means to locate the iimage in the top right corner
playa.topright = 0,10
# screen width based on the width of the playa
WIDTH = 500
# height based on the playa height + 20
HEIGHT = playa.height + 20

def draw():
# put all the screen black
screen.clear()
# draw the image in the screen
playa.draw()

def update():
# number of the velocity of the image
playa.left += 4
if playa.left > WIDTH:
playa.right = 0

``````

This is a videotutorial showing how to create a basic game named game1.py:

### Guess 2

This is he code to guess the number I'm thinking using python

``````
import random  # random is a python library to create random numbers

n = random.randint(15, 150)  # n is a integer number from 15 to 150
guesses = 0  # guesses is a variable with initial value 0

while True:  # do the following code all the time counting up guesses
guesses = guesses + 1  # add a guess every time I try to answer
print("I am thinking of a number, between 15 and 150 can you guess what it is?")  # show in the screen this question
g = int(input())  # g is a number entered by the user (input()
if g == n:  # if the number entered by the user is equal to the random number the code stops
break
elif g < n:  # if the number entered by user is minor than the random number tell the user "this number is too low, try a high number"
print("This number is too low, try a high number")
elif g > n:  # if the number ntered by user is more than the random number tell the user "this number is too high, try to say a low number"
print("This number is too high, try to say a low number")
print("Correct! That's the number I was thinking about", guesses, "attempts you try.")
# if the number entered by the user is correct tell the user "Correct!..."
# tell the user also the number of attempts
``````