# class assignment shenting wang

```
import rhinoscriptsyntax as rs
import math as mt
import random as rd
def exer01():
"""create a list and use it for itertaion
"""
mylist = range(10) # [0,1,2,...,9] start at 0, ending is 10 - 1
print mylist
mylist = range(1,10)
print mylist
mylist = range(1,5) # 5 is the ending number excluding itself
print mylist
mylist = range(1,20, 2) # starts at 1, ending at 20-1, increase with a step 2
print mylist
mylist = range(40, -1, -2)
print mylist
mylist = rs.frange(0, 10, 0.5)
print mylist
mylist = range(100)
def makeTriangles(item):
p0 = item,          item,       0
p1 = item + 1,      item,       0
p2 = item + 0.5,    item + 1,   0
points = p0,p1,p2,p0
def makeTriangles2(item, id):
p0 = 0,      0,       0
p1 = 1,      0,       0
p2 = 0.5,    1,       0
origin = 0,0,0
scale = item+1, item+1, item+1
id = rs.ScaleObject(id, origin, scale, True)

center = origin
id = rs.RotateObject(id, center, angle)

translation = item, item, 0
id = rs.MoveObject(id, translation)
return id
def makeTriangles3(item):
p0 = 0,      0,       0
p1 = 1,      0,       0
p2 = 0.5,    1,       0

origin = 0,0,0
scale = item+1, item+1, 1
id = rs.ScaleObject(id, origin, scale)

center = origin
id = rs.RotateObject(id, center, angle)

translation = item, item, 0
id = rs.MoveObject(id, translation)
def makeInitialShape(item,id):
origin = 0,0,0
scale = item/10+1, item/10+1, 1
id = rs.ScaleObject(id, origin, scale,True)

center = origin
id = rs.RotateObject(id, center, angle)

translation = item, item, 0
id = rs.MoveObject(id, translation)
return id

def exer02():
""" make a for loop using a list
"""
id = rs.GetObject()
mylist = range(10)
for item in mylist:
id = makeInitialShape(item, id)
mirror1 = rs.MirrorObject(id,[0,0,0],[0,1,0],True)
mirror2 = rs.MirrorObjects (mirror1,[0,0,0],[1,0,0],True)
mirror3 = rs.MirrorObjects (id,[0,0,0],[1,0,0],True)
print id

def exer03():# make a field of points vertically
xlist = range(10) # 0,1,2,3,...9
ylist = range(10)
for x in xlist:
for y in ylist:
point = x,y,0
rs.Sleep(500)

ylist = range(10)
for y in ylist:
point = x,y,0
#print point
rs.Sleep(500)
def exer03B():# make a field of points vertically
xlist = range(10) # 0,1,2,3,...9
for x in xlist:

def exer04():# make a field of points horizontally
xlist = range(10) # 0,1,2,3,...9
ylist = range(10)
for y in ylist:
for x in xlist:
point = x,y,0
#print point
rs.Sleep(500)
def exer05():# make a filed of cube (3D)
xlist = range(10) # 0,1,2,3,...9
ylist = range(10)
zlist = range(10)
for x in xlist:
for y in ylist:
for z in zlist:
point = x,y,z
#print point
rs.Sleep(10)

center = x,y,0
def exer06():
attractor = rs.GetPoint()
print attractor
xlist = range(30)
ylist = range(30)
for x in xlist:
for y in ylist:
#calculate distance
pt1 = attractor
pt2 = x,y,0
distance = rs.Distance(pt1, pt2)
#make a cylinder
base = x,y,0
height = distance/50

def main():
#exer01()
exer02()
#exer03()
#exer04()
#exer05()
#exer06()
main()

__ATA.cmd.push(function() {
__ATA.initVideoSlot('atatags-370373-5e8f8b5a32d5a', {
sectionId: '370373',
});
});

__ATA.cmd.push(function() {
__ATA.initDynamicSlot({
id: 'atatags-26942-5e8f8b5a32dac',
location: 120,
formFactor: '001',
label: {
},
creative: {