DEV Community

Cover image for Let's Make the Computer Think of a Number with Python
Daniel Nogueira
Daniel Nogueira

Posted on

Let's Make the Computer Think of a Number with Python

A practical way of doing that's using the random library. Let's import it:

import random
Enter fullscreen mode Exit fullscreen mode

Among the random methods, there is the randint method, that returns an integer value within a specified range.

random.randint(0,10)
Enter fullscreen mode Exit fullscreen mode

Just use a variable to store the value the function will return and that's it, we can display the value the computer thought.

x = random.randint(0,10)
print(x)
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more