Try random.randrange:
from random import randrange
print(randrange(10))
Answer from kovshenin on Stack OverflowPython documentation
docs.python.org › 3 › library › random.html
random — Generate pseudo-random numbers
February 23, 2026 - Print a random integer between 1 and N inclusive, using randint(). ... Print a random floating-point number between 0 and N inclusive, using uniform().
Whats your preferred way of generating a random number, e.g. between 1 and 100 ?
random.randint(0, 100) More on reddit.com
How to generate random integers (0-9) in Python? - TestMu AI Community
How to Generate Random Integers Between 0 and 9 in Python? How can I generate random integers between 0 and 9 (inclusive) in Python? For example, I want to get numbers like 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. Can you show me how to generate a random integer Python between 0 and 9? More on community.testmu.ai
I made a code that outputs a list of 10 random numbers and below it reprints it in numerical order. Considering I started learning Python less than 1 week ago, I am pretty proud of myself.
Every great journey begins with a single step More on reddit.com
Generate 10 random numbers between 0-100. No more than 3 in a sequence and no more than 4 in 10s, 20s, ..., 90s. - Python
Use lists for the counts The range 0-9, 10-19, 20-29, and so on can easily be mapped to the range 0,1,2,3,4... via integer division // in Python. This result can be used as index for the lists I mentioned in 1 - this way, you don't need a huge if-elif-else chain, in fact, you don't even need a single if. More on reddit.com
Videos
08:05
Python Tutorial #7: Random Numbers 🐍 - YouTube
08:03
Generate random numbers in Python 🎲 - YouTube
00:54
How To Generate Random Numbers In Python - YouTube
Python program to generate a random number between 1 &10 ...
02:55
Write A Python Program To Generate Random Numbers Between 1 And ...
Reddit
reddit.com › r/learnpython › whats your preferred way of generating a random number, e.g. between 1 and 100 ?
r/learnpython on Reddit: Whats your preferred way of generating a random number, e.g. between 1 and 100 ?
January 25, 2022 -
Looking to create a random number between 1 and 100. Actually 0 (zero) is valid too, so between 0-100.
Whats your preferred way of dong that in Python?
Top answer 1 of 13
32
random.randint(0, 100)
2 of 13
22
I use list comprehensive to generate a list of all numbers 0 - 100. Then I use random.randint to generate a number between 0 - 100, and I shuffle the list that number of times. Then I use random.randint to generate another number between 0 - 100, which I use as the index for the element I select from my shuffled list, giving me my random number. Jk. random.randint(0,100)
W3Schools
w3schools.com › python › gloss_python_random_number.asp
Python Random Number
Python does not have a random() function to make a random number, but Python has a built-in module called random that can be used to make random numbers: Import the random module, and display a random number between 1 and 9: import random print(random.randrange(1,10)) Try it Yourself » ·
JustAnswer
justanswer.com › computer-programming › 6w5hq-i-m-trying-generate-10-random-numbers-numbers.html
I'm trying to generate 10 random numbers between the numbers 1 - 10. int i = 1 + rand() % (10); I'm putting these 10
I'm trying to generate 10 random numbers between the numbers 1 - 10. int i = 1 + rand() % (10); I'm putting these 10
GeeksforGeeks
geeksforgeeks.org › python › python-generate-random-numbers-within-a-given-range-and-store-in-a-list
Generate random numbers within a given range and store in a list - Python - GeeksforGeeks
May 5, 2025 - import numpy as np no = 10 a = 10 # start b = 40 # end res = np.random.randint(a, b + 1, size=no).tolist() print(res) ... Explanation: randint() quickly generates 10 random numbers between 10 and 40 in one go.
GitHub
github.com › meta-pytorch › OpenEnv › blob › main › tutorial › 01-environments.md
OpenEnv/tutorial/01-environments.md at main · meta-pytorch/OpenEnv
import random print("🎲 " + "="*58 + " 🎲") print(" Number Guessing Game - The Simplest RL Example") print("🎲 " + "="*58 + " 🎲") # Environment setup target = random.randint(1, 10) guesses_left = 3 print(f"\n🎯 I'm thinking of a number ...
Author meta-pytorch
Instagram
instagram.com › popular › python-random-number-between-1-and-10
Python Random Number Between 1 And 10
March 25, 2026 - We cannot provide a description for this page right now
RANDOM.ORG
random.org › integer-sets
RANDOM.ORG - Integer Set Generator
This page allows you to generate random sets of integers using true randomness, which for many purposes is better than the pseudo-random number algorithms typically used in computer programs.
Matplotlib
matplotlib.org › stable › tutorials › pyplot.html
Pyplot tutorial — Matplotlib 3.10.9 documentation
import matplotlib.pyplot as plt plt.plot([1, 2, 3, 4]) plt.ylabel('some numbers') plt.show() You may be wondering why the x-axis ranges from 0-3 and the y-axis from 1-4. If you provide a single list or array to plot, matplotlib assumes it is a sequence of y values, and automatically generates the x values for you. Since python ranges start with 0, the default x vector has the same length as y but starts with 0; therefore, the x data are [0, 1, 2, 3].