# Numpy is imported, seed is set
# Starting step
step = 50
# Roll the dice
dice = np.random.randint(1,7)
# Finish the control construct
if dice <= 2 :
step = step - 1
elif dice <= 5 :
step = step + 1
else:
step = step + np.random.randint(1,7)
# Print out dice and step
print(dice)
print(step)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter