Skip to content
Sign UpLog In
This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs
5

Python Random Number Generator Tutorial

tankerguy1917
tankerguy1917

This is a tutorial for a simple random number generator in python. if it is to hard to see in the program, here is the code

import random
from random import choice

rand_num_list = [1, 2, 3, 4, 5]

rand_num_list = choice(rand_num_list)
print(rand_num_list)

Hope you enjoy, and I hope it helps
:)

2 years ago

Voters

Comments

TopNew
1
Owenkop
Owenkop

is it posible to make this select multiple numbers so it would selct 5 random numbers from the numbers (sort of like this 11385)?

2 years ago
1
tankerguy1917
tankerguy1917

@Owenkop
maybe [this] (https://replit.com/@tankerguy1917/multiple-random-numbers#main.py) will help. If it doesn't, just let me know and we can try to find a solution for you :)

2 years ago
1
tankerguy1917
tankerguy1917

@Owenkop
Also, I made this a long time ago, and it is better to just use random.randint. The only time I'd say that you wouldn't want to use randint is if you only want a few specific numbers instead of 1 through 0.

2 years ago
Load more