from visual import * 

N=25

my_list=[] #Just like in octave, this tells Python that my_list will be a list.

for i in range(N): #The range() function returns an N element array 0,1,...N-1

    my_list+=[sphere(pos=(2*i-N,0,0),radius=0.5)] #Add elements to the my_list array.
    
    if i%3==0: #Turn every third sphere blue 

        my_list[i].color=color.blue

        my_list[i].velocity=vector(0,1,0) #Velocity points in the y-direction.

    else:
        my_list[i].velocity=vector(1,0,0) #Otherwise, velocity points in the x-direction.

dt=0.01

while 1: #Animate!
    scene.autoscale=0
    rate(1/dt)

    for ball in my_list: #Another way of doing for loops in python.  The program will step through every object in my_list and update its position.
        
        ball.pos+=ball.velocity*dt
        
    
