# import the random number generator import random # Create two loops, one to increment the days, and one to generate 3 random encounters per day # for days 1 through 80 for day in range (1,81): # generate an encouter at a random hour three times per day for count in range (0,3): # generate a random hour on the 24 hour clock, from 0:00 to 23:00 hour=random.randint(0,23) # generate a random encounter from a random encounter table with 20 types of encounters encounter=random.randint(1,20) # print the output in three columns, Day, Time, Encounter Type print('Day %s Time %s:00 Encounter Type %s' % (day, hour, encounter)) count += 1 # increase the counter for encounter generation by 1 day += 1 # increate the day count by 1
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question