List access, condition statements

1. item access

Place GhPython components like this.
1.png
For the time being, we keep using Item Access
3.png
The codes on "from" and "to" ends are:
2.png
You will get
4.png

2. item access

Let's switch to List Access.
5.png
Now, the "To" end component turned to Red. This is because circle is a list type object and not a tuple.
Let's modify the code a little bit.
6.png
You will get the same result as the previous one.
4.png

3. Gaussian hill

Surface version of the Gaussian function.
7.png

import rhinoscriptsyntax as rs
import math
F=lambda x,y:(
A*math.exp(-((x-x0)**2+(y-y0)**2)/
(2*(C**2))))
a=list()
for i in rs.frange(-1.0,1.0,0.05):
    for j in rs.frange(-1.0,1.0,0.05):
        a.append(rs.AddPoint(i,j,F(i,j)))

8.png

4. Splitting Gaussian Hill

9.png
10.png
11.png

5. Gaussian hill with List Access

Let's change the access type of "hill" to List Access.
Let's rename the "hill" "hills".
12.png
Our new code for To end is

import rhinoscriptsyntax as rs
import math
 
_F=lambda x,y,A,C,x0,y0:(
    A*math.exp(-((x-x0)**2
    +(y-y0)**2)/(2*(C**2))))
def F(x,y):
    z=0
    for hill in hills:
        (A,C,x0,y0)=hill #Unpacking
        z+=_F(x,y,A,C,x0,y0)
    return z
a=list()
for i in rs.frange(-1.0,1.0,0.05):
    for j in rs.frange(-1.0,1.0,0.05):
        a.append(rs.AddPoint(i,j,F(i,j)))

Note that
F=lambda x:x**2

is equivalent to
def F(x):
    return x**2

If you duplicate From end like this
13.png

You may get somthing like this
14.png

6. Condition statements

a=1
print a==1 
print a==2
print a<1
print a<=1
print a!=1
a=1
b=2
print a==1 and b==2
print a==1 or b==2
print a==1 and b==3
print a==1 or b==3