How to use python to make a random generator?

 How do i make a random generator with parameters using python?

My goal is to use python to tell me what t-shirt to wear. but  i don't want to wear the same shirt more than once a week.  I figure you're allowed to make brain processing light in the morning :P

btw i'm a beginner so i want to learn but still get the product.

sort by: active | newest | oldest
yokozuna7 years ago
An easy psuedo generator which should suffice for your project:

import random
print random.randrange()

Just put the range in the parenthesis.
Fored yokozuna7 years ago
And if you don't want the same t-shirt to be chosen twice in a week, you can keep a stack of the last seven shirts and either choose again if the random selected happens to be in the stack, or copy the whole list of shirts, remove the ones in the stack, and choose randomoly from this "clean" list.
RyanJ931 year ago


I got inspired by your post and made the app in question check it out
import random #This imports a module for randomness

/t Welcome to the random shirt generator!
/t Your shirt will be generated now
#This prints a centered title. You can use triple quotes to make a really long #multi line string.

#Optional: Put a while statement here to make this a loop instead of a
# one run and done python script.

Shirt_Choice = random.random.randint(1, 100)
#^This assigns a variable to a random number 1 - 100

#v This is going to show you how to do your conditional satements v
If 1<=Shirt_Choice<=10:
print"Wear The blue shirt"
#What this is saying is that if the randomly generated number is greater then #or equal to 1 and less then or equal to 10 then print Wear the blue shirt.
# You can easily mess with that and make the program how you want it.
Lay out all the shirts on a flat surface in a circle. Place the python in the center, and wear the first shirt that it slithers across. Do laundry every seven days or greater to reset the shirt options.
Just so you know, I absolutely died laughing when I read that. :P
Thank you. My goal is to provide interesting, informative and useful answers to questions.

Clearly, I need a new goal.
I was going to suggest having the python roll a d8 and if an eight was rolled, wear no shirt at all.  But your suggestion is more in line with the original question.


What's the saving throw vs. T-shirts, anyway? We'd also need to know the THAC0 of the python, I guess....