Pick a number (WSQ06)

This homework is really fun, because I need to create a game, so the user should guess which number the program did choose.

I didn’t know how to print/choose a random number, this website helped me out. The variable for the random number will be “x”

Alright, the range that I need is from 1 to 100. While proving the code, I’ll print the random number, but I’ll erase line 3 when I end up the homework. pick a number 01

Then I need the user to guess my number, so I enter an input. And of course I assign it a variable, “y”.

pick a number 02

After that, we start with the “if” sentences.

pick a number 03

As we want our user to guess, we need to give him/her some clues. If he/she typed a lower or higher number, the program should print which is the problem.

Up to here, the result is this:

pick a number 04

Now I’ll say the user how many times he/she needed to guess the right number, and I’ll also comment line 3.


Aaand there we go… 😀 Here’s my code, you can download it if you need/want to.

See ya..!



Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión /  Cambiar )

Google photo

Estás comentando usando tu cuenta de Google. Cerrar sesión /  Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión /  Cambiar )

Conectando a %s