Welcome, guest | Sign In | My Account | Store | Cart
 import random

min=1
max=12

roll_again = 'yes'

die1=random.randint(min,max)
die2=random.randint(min,max)

while roll_again == 'yes' or roll_again == 'y':
    die1=random.randint(min,max)
    die2=random.randint(min,max)
    print ('shake, shake, shake!')
    print ('you got a:')
    print die1
    print die2

    print ('the sum of your two numbers are below:')
    print die1 + die2
    roll_again = raw_input ('roll the dice again')

Diff to Previous Revision

--- revision 1 2014-06-12 22:01:20
+++ revision 2 2014-06-12 22:03:16
@@ -1,52 +1,21 @@
-#!/usr/bin/env python
+ import random
 
-import string
-from time import time
-from itertools import chain
-from random import seed, choice, sample
+min=1
+max=12
 
+roll_again = 'yes'
 
-def mkpasswd(length=8, digits=2, upper=2, lower=2):
-    """Create a random password
+die1=random.randint(min,max)
+die2=random.randint(min,max)
 
-    Create a random password with the specified length and no. of
-    digit, upper and lower case letters.
+while roll_again == 'yes' or roll_again == 'y':
+    die1=random.randint(min,max)
+    die2=random.randint(min,max)
+    print ('shake, shake, shake!')
+    print ('you got a:')
+    print die1
+    print die2
 
-    :param length: Maximum no. of characters in the password
-    :type length: int
-
-    :param digits: Minimum no. of digits in the password
-    :type digits: int
-
-    :param upper: Minimum no. of upper case letters in the password
-    :type upper: int
-
-    :param lower: Minimum no. of lower case letters in the password
-    :type lower: int
-
-    :returns: A random password with the above constaints
-    :rtype: str
-    """
-
-    seed(time())
-
-    lowercase = string.lowercase.translate(None, "o")
-    uppercase = string.uppercase.translate(None, "O")
-    letters = "{0:s}{1:s}".format(lowercase, uppercase)
-
-    password = list(
-        chain(
-            (choice(uppercase) for _ in range(upper)),
-            (choice(lowercase) for _ in range(lower)),
-            (choice(string.digits) for _ in range(digits)),
-            (choice(letters) for _ in range((length - digits - upper - lower)))
-        )
-    )
-
-    return "".join(sample(password, len(password)))
-
-
-print mkpasswd()
-print mkpasswd(12)
-print mkpasswd(digits=3)
-print mkpasswd(12, upper=4)
+    print ('the sum of your two numbers are below:')
+    print die1 + die2
+    roll_again = raw_input ('roll the dice again')

History