from random import randint def choose_die(): incolor = int(raw_input("How many are in color: ")) outcolor = int(raw_input("How many are out of color") die_in = 0 die_out = 0 for i in range(incolor): if randint(1,6) == 1 or randint(1,6) == 2: die_in = die_in+1 for i in range(outcolor): if randint(1,6) in [1,2,3,4]: die_out = die_out+1 print "In color", die_in, " died." print "Out color", die_out, " died." def choose_children(): amountg = int(raw_input("How many green couples are reproducing: ")) amountb = int(raw_input("How many beige couples are reproducing: ")) totalg = 0 totalb = 0 for i in range(amountg): totalg = totalg + randint(1,6) for i in range(amountb): totalb = totalb + randint(1,6) print "There are", amountg, " green kids." print "There are", amountb, " beige kids." while True: choice = int(raw_input("Do you want (1) to choose death or (2) choose kids: ")) if choice == 1: choose_die() elif choice == 2: choose_children() else: print "INVALID"
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