In this publication we develop a program that selects a random integer in the range of 1 to 100, you could say that it is easy but if you have a minimal error, the program does not work (own experience).
We will start importing from the library the radom function, we will give x value a range between (1,100), the program like you can do things as simple as your name or welcome. After the presentation of the program we must add counters equal to 0 to store the different processes that are performed.

In this opportunity, at the moment of entering in which we will! = To give it a difference of x, and we will integrate the number of tries in which the program can be realized.

We will start by asking a numeor and we will analyze it with 2 if one to say if the value of x is bigger you need to reduce it and on the contrary if the value is very small if you need to increase it, if the result is equal to that the machine has a happiness, But If the points of the attempts of the machine will end the process and say a sorry.

In each of the links if you have to add a counter that matches the number of attempts already taken, giving a + 1.

In this post, we use mastering topic like:

  • Basic output (print)
  • Basic user input (text based)
  • Importing and using modules/libraries
  • Use of the conditional “if”
  • Use of “else” with a conditional (and elif for Python)
  • Use of loops with “while”

16788113_1533327513358936_1804293810_n

 

Results:

16788113_1533329713358716_573165028_n