#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    6
    Rep Power
    0

    Hom work Help (Random)


    Hello i need a help

    inum1=random.randrange(0,50)
    inum2=random.randrange(0,35)
    inum3=random.randrange(0,600)
    how can i make that this code in loop evry time the numbers will be lower and lower and not gust diferent from each other in allot numbe?
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,997
    Rep Power
    481
    Monte-Carlo simulation of some sort of situation.
    Code:
    import random
    L = []
    while len(L) < 100:
        (n, count,) = (9999, 0,)
        while n:
            count += 1
            n = random.randrange(n)
        L.append(count)
    
    print('mean number of trials: %g'%(sum(L)/float(len(L))))
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    6
    Rep Power
    0
    Originally Posted by b49P23TIvg
    Monte-Carlo simulation of some sort of situation.
    Code:
    import random
    L = []
    while len(L) < 100:
        (n, count,) = (9999, 0,)
        while n:
            count += 1
            n = random.randrange(n)
        L.append(count)
    
    print('mean number of trials: %g'%(sum(L)/float(len(L))))

    can you please make it more simple.
    i cant use this simbols.

    thank for helping
  6. #4
  7. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,997
    Rep Power
    481
    Code:
    import random
    
    n = 99999                               # in allot numbe?
    
    while n:                                # code in loop
        print(n)
        n = random.randrange(n)          # numbers will be lower and lower
    
    print(n)  # (zero)
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo