# WSQ-03

--Originally published at Program

Write a program that picks a random integer in the range of 1 to 100.

There are different ways to make that happen, you choose which one works best for you.

It then prompts the user for a guess of the value, with hints of ’too high’ or ’too low’ from the program.

The program continues to run until the user guesses the integer. You could do something extra here including telling there user how many guesses they had to make to get the right answer.

# # WSQ 03 – Pick a Number

--Originally published at マルコ

## What to Do

There are different ways to make that happen, you choose which one works best for you.Write a program that picks a random integer in the range of 1 to 100.

It then prompts the user for a guess of the value, with hints of ’too high’ or ’too low’ from the program.

The program continues to run until the user guesses the integer. You could do something extra here including telling there user how many guesses they had to make to get the right answer.

You might want to check that your program doesn’t always use the same random number is chosen and you should also split your problem solving into parts. Perhaps only generate the random number and print that as a first step.

Featured Image:

# Pick a number

--Originally published at Programming

The instructions was: Write a program that picks a random integer in the range of 1 to 100.

Then, you will try to guess that number. If you are up the value write something like “too big” and “too small” if you are under.

Here is the code:

First, we import random. Then we declared that num will be the number we will being trying to guess. In that part we write the range (the orange numbers). After that, we print a little description for the user from our programm. Then we declared guess that is the number the user introduce (remeber, put like and int), and a that is our counter of tries.

The program continues to run until the user guesses the integer and at the end we print how many tries he/she made.

And now, let’s play!

# WSQ-03

--Originally published at Site Title

En esta ocasión se debe de desarrollar un programa que elija un número aleatorio del 1 al 100 y que de oportunidad al usuario de adivinarlo.

En este caso importamos random para que el programa tenga la capacidad de escoger un número de manera aleatoria. Una vez que hacemos esto, simplemente creamos el while para que el usuario intente adivinar el número.

Para realizar este programa me apoye en la siguiente página:

http://www.pythondiario.com/2013/06/modulo-random-en-python-con-ejemplos.html

# Pick a number!

--Originally published at Python learning

This time I’m going to show a program that chooses a random number from 0 to 100 and then asks the user to guess this number. To make it easier to guess, it gives clues by stating if the number entered is higher or lower than the one chosen. Also, when finally guessed, it says how many tries it took the user to do so.

In order for me to learn how to do this, I checked the following page: http://www.pythonforbeginners.com/random/how-to-use-the-random-module-in-python

At first I had a small problem because I wanted to use ‘try’ as a variable name, but I forgot in python that one is a keyword, which are specific words already used in order to tell the program what to do. So naturally, when I tried to run it my program marked SyntaxError: invalid syntax.

Once I realized the mistake I had made, I changed the variable to ‘number_guess’ and everything was fine! Here is where I got more information about keywords so I wouldn’t make that mistake again: http://www.pythonforbeginners.com/basics/keywords-in-python

After that, this is how I wrote my code:

And it runs like this:

# WSQ03 – Pick a number

--Originally published at Stuff about Python

Hi there, today in response to WSQ03, I wrote a small program that defines a random number between 0 and 100, and lets the user try to guess it while giving him a hint whenever he is wrong. Here it is :

I imported the randint() function from the random module, that lets you define a random integer in a range chosen.

After defining that principal number, n, I let the user try to guess it using the input() function, and check with conditional statements if the number entered is the same than the random number.

If it is, the user wins. Otherwise, the number of guesses is kept track of, and a hint is given : ‘too high’ or ‘too low’.