Saturday, May 14, 2011

Matrix effect code in Python

Here is kind of Matrix effect of random numbers running on the screen.
If you know Matrix movie you'll understand what I'm talking about. It is my first and I hope not last try of coding on Python )).

#!/usr/bin/python

import random

start = 11
stop = 99
i = 0

def buildNumberTable(j):
        i = 0;
        list = []
        while i <= j:
                a = random.randrange(start, stop)
                list.append(a)
                i += 1;
        for b in list: print b,
print "\r"

while (i <= stop):
    buildNumberTable(66); #the parameter 66 fits to 15.4" screen if you have 13" put dif. number
    i += 1
    if i == stop:
i=0




No comments: