[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

I am playing with python and I am interested to know any cool

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 9
Thread images: 3

File: dank.png (392KB, 675x411px) Image search: [Google]
dank.png
392KB, 675x411px
I am playing with python and I am interested to know any cool ways to generate random numbers.
>>
import random
if you're just dicking around
from os import urandom
if you want actual randomness
>>
>>55789131
int get_random()
{
return 4; // Chosen by a fair dice roll.
// Guaranteed to be random.
}
>>
File: dank.jpg (41KB, 1280x720px) Image search: [Google]
dank.jpg
41KB, 1280x720px
>>55789485
>It doesn't work
from os import urandom

main_numbers=[]
main_number_count=0


while main_number_count<4:
number=random.sample([
1, 2, 3


], 1)
main_numbers.append(number)
main_number_count+=1


print (main_numbers)
>>
>>55789131
Mersenne twister
>>
mouse pointer position
>>
>>55791972
oh sorry, you wrote "cool" ways
I'm legally blind
>>
>>55789959
are you stealing from xkcd or smbc? i can't remember
>>
File: Capture.png (10KB, 256x303px) Image search: [Google]
Capture.png
10KB, 256x303px
>>55790013
stop it.
Thread posts: 9
Thread images: 3


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

If you need a post removed click on it's [Report] button and follow the instruction.
If you like this website please support us by donating with Bitcoin at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties. Posts and uploaded images are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that website. If you need information about a Poster - contact 4chan. This project is not affiliated in any way with 4chan.