[Tutor] random number equations . . .

Dragonfirebane at aol.com Dragonfirebane at aol.com
Thu Jun 3 17:32:54 EDT 2004

I don't want to write my own equations for creating random numbers (based on 
'time.time()'), but i need random numbers to create account id's and assign 
starting money in the program segment below . . . i would use [import random *] 
but i'm not sure which section of random is a random number generator or the 
syntax necessary to apply it.  Any help would be appreciated.

def newuser():  
    new = raw_input("Are you a new user [y/n]? ")   
    while new not in 'yYnN':    
        new = raw_input("""
        Please enter 'y' for yes or 'n' for no.
        Are you a new user? """)
    if new in 'yY': 
        import math
        vowelcount = 0  
        name = raw_input("Please enter your first name. ")
        name = name[:6]
        namel = raw_input("Please enter your last name. ")  
        namel = namel[:6]   
        name = name + ' ' + namel
        vowels = ['a','e','i','o','u','A','E','I','O','U']  
        for letter in name: 
            if letter in vowels:    
                vowelcount = vowelcount + 1 
        global startmon 
        global tim  
        tim = time.time() % 100000
        startmon = vowelcount * tim  
        startmon = math.sqrt(startmon) * 3141.5962    
        startmon = str(startmon)[:7]  
        startmon = int(float(startmon))    
        print "Welcome, %s.  You have $%d to use in BankSim 1.0." % (name, 
def newacc():   
    global newac    
    newac = raw_input("Would you like to create a new account [y/n]? ") 
    while newac not in 'yYnN':  
        newac = raw_input("""
        Please enter 'y' for yes or 'n' for no.
        Would you like to create a new acount [y/n]? """)   
    if newac in 'yY':   
        import math 
        global newacid 
        newacid = int(raw_input("Please enter your birthday [ddmmyyyy]. ")) 
        newacid = newacid * tim  
        newacid = math.sqrt(newacid) * 314.15692   
        newacid = str(newacid)[:6]  
        newacid = int(float(newacid))
        initbal = int(raw_input("How much money would you like to put in your 
account? "))  
        print "Account number %d created with $%d in it." % (newacid, initbal)
        mon = startmon - initbal
        print "You now have $%d in account %d and $%d out of the bank." % 
(initbal, newacid, mon)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20040603/56f8ff95/attachment.html

More information about the Tutor mailing list