--Originally published at Elu's Blog
For this assignment, this were the instructions:
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.
This is my code:
Libraries are collections of tools and resources for programmers. They may include functions or data. To use a library in Python3, you have to use the word “import” before the name of the library, or you can use “from ‘name-of-the-library’ import ‘name-of-the-function'”. In my code I imported the ‘random’ library and I used the random.randrange() function which gets you a number from the range that you specify.
The range function in Python3 is used by telling it the first number and the last number of the range. Personally, I use it very often in for loops when using lists.