# Intro to Python Scripting: 05 For Loop and Math Library

Software:
Tag:
Video Duration:
12 minutes
Author:
Zach Downey

In this tutorial we take a closer look at the for loop. Specifically the for range loop and the frange loop (which is unique to rhinoscript). We also introduce the sin and cosine function via python's Math library. This is done by import the math library with an import statment. We create a couple of 2D sine waves and and spiral by combining the functions.

```#For Loop to Create Points
#For Loop using the range and frange functions

import rhinoscriptsyntax as rs
import math

#Simple Count
for i in range(0,50):
print(i)

#Count by Even Numbers
for i in range(0, 50, 2):
print(i)

#Count by Odd Numbers
for i in range(1,50,2):
print(i)

#Using Rhinoscript's frange to step with floats
for d in rs.frange(0.0, 10.0, 0.1):
print(d)

for d in rs.frange(0.0, 10.0, 0.1):

points = []

for d in rs.frange(0.0, 10.0, 0.1):
x = d*math.sin(d)
y = d*math.cos(d)
z = 0.0
pt = (x,y,z)
points.append(pt)

### Rating

Please rate this tutorial below. Thanks.