TLC and Python
https://learn.foundry.com/nuke/8.0/content/user_guide/expressions/converting_expressions.html
nuke.expression()# to use a Nuke expression in TCL.
expression
# to run TCL code in Python.
nuke.tcl()
# to run Python code in TCL
python
# (square brackets) to embed TCL in a Nuke expression (or a string knob)
[ ]
# to embed Python in a Nuke expression.
[python {...}]
Variables & Expressions
# This makes a decimal number a whole number ( 2.75 = 2 )
int(x)
# This makes negative numbers positive.
abs(x)
# Make s a value a string, good for text
str(x)
TLC
[value variable]
# Get the frame variables
frame first_frame last_frame
format.x format.y  xxx
# Get the horizontal and vertical number
width height
# Get the left and bottom bounding box location
bbox.x bbox.y
# Get the right and top bounding box location
bbox.r bbox.t
# Get the width and height bounding box location
bbox.w bbox.h
Strings
string = "One, Two, Three, Four"
Conditions
IF THEN
Python:
if expression:
statement(s)
else:
statement(s)
TLC:
A > B ? True : False
[if {A > B} {True} {False}]
FOR LOOPS
for x in range(0, 10):
print x
string = ['one', Two, '3', 'four']
for x in string:
print x
WHILE LOOPS
loops = 10
while (loops <= 10):
loops = loops + 1
.
Expressions
http://www.nukepedia.com/writtentutorials/expressions101
Gradient x / width
y / height
1  (y / height)
Lines sin(x)
sin(x) + 1
( sin(x) + 1 ) / 2
( sin(x / 4 ) + 1 ) / 2
Radial Gradient sqrt(x * x + y * y )
300  sqrt(x * x + y * y )
(300  sqrt( x * x + y * y ) ) / 300
Radial Rings sin(sqrt(x * x + y * y ))
sin(sqrt(x * x + y * y ) / 4)
Random
(random(123,frame*0.1)*0.5)+0.5  (random(seed,frame*frequency)*amplitude)+valueOffset
https://www.cameroncarson.com/nukewaveexpressions
RANDOM WAVE
random((frame+offset)/waveLength) * (maxValminVal) + minVal
NOISE WAVE
(noise((frame+offset)/waveLength)+1)/2 * (maxValminVal) + minVal
SINE WAVE
(sin(2*pi*(frame+offset)/waveLength)+1)/2 * (maxValminVal) + minVal
TRIANGLE WAVE
(asin(sin(2*pi*(frame+offset)/waveLength))/pi+0.5) * (maxValminVal) + minVal
SQUARE WAVE
int(sin(2*pi*(frame+offset)/waveLength)+1) * (maxValminVal) + minVal
SAWTOOTH WAVE
((frame+offset) % waveLength)/waveLength * (maxValminVal) + minVal
SAWTOOTH (PARABOLIC) WAVE
sin((pi*(frame+offset)/(2*waveLength)) % (pi/2)) * (maxValminVal) + minVal
SAWTOOTH (PARABOLIC REVERSED) WAVE
cos((pi*(frame+offset)/(2*waveLength)) % (pi/2)) * (maxValminVal) + minVal
SAWTOOTH (EXPONENTIAL) WAVE
(exp(2*pi*((frame+offset) % waveLength)/waveLength)1)/exp(2*pi) * (maxValminVal) + minVal
BOUNCE WAVE
abs(sin(pi*(frame + offset)/waveLength))* (maxValminVal) + minVal
BLIP
((frame+(offset+waveLength)) % (waveLength+blipLength)/(waveLength)) *(waveLength/blipLength)  (waveLength/blipLength) >= 0 ? maxVal : minVal
SINEBLIP
((int((frame+offset) % waveLength)) >= 0 ? ((int((frame+offset) % waveLength)) <= (0+(blipLength1)) ? ((sin(pi*((frame+offset) % waveLength)/blipLength)/2+1/2) * (2*maxVal2*minVal) + (2*minValmaxVal)) : minVal) : minVal)
Bounding box
bbox.x bbox.y bbox.r bbox.t
Get the input width and height
.width .height
Get input first and last frame
.first_frame and .last_frame
Name of the node
.name
Will look for the original node
.root
Python
Get Script Name
os.path.basename(nuke.root().name()).split('_v')[0]
Get Version
os.path.basename(nuke.root().name()).split(getUserVersion)[1].split('.nk')[0]
Get File
inspect.getfile(inspect.currentframe())
Get Folder
os.path.dirname(inspect.getfile(inspect.currentframe()))
Rendering tips
 Adding “/5″ to the end of you render frames will render every 5th frame i.e. 1100/5
Mathematical Functions
Function 
Purpose 
Operator Usage 
Related Functions 
DeepExpression Compatible 

abs (x) 
Returns the absolute value of the floatingpoint number x. 
x 
See also: fabs. 

acos (x) 
Calculates the arc cosine of x; that is the value whose cosine is x. 
If x is less than 1 or greater than 1, acos returns nan (not a number). 
See also: cos, cosh, asin, atan. 

asin (x) 
Calculates the arc sine of x; that is the value whose sine is x. 
If x is less than 1 or greater than1, asin returns nan (not a number). 
See also: sin, sinh, acos, atan. 

atan (x) 
Calculates the arc tangent of x; that is the value whose tangent is x. The return value is between PI/2 and PI/2. 
x 
See also: tan, tanh, acos, asin, atan2. 

atan2 (x, y) 
Calculates the arc tangent of the two variables x and y. This function is useful to calculate the angle between two vectors. 
x, y 
See also: sin, cos, tan, asin, acos, atan, hypot. 

ceil (x) 
Round x up to the nearest integer. 
x 
See also: floor, trunc, rint. 

clamp (x, min, max) 
Return x clamped to [min … max]. 
x, min, max 
See also: min, max. 

clamp (x) 
Return x clamped to [0.0 … 1.0]. 
x 
See also: min, max. 

cos (x) 
Returns the cosine of x. 
x in radians 
See also: acos, sin, tan, cosh. 

cosh (x) 
Returns the hyperbolic cosine of x, which is defined mathematically as (exp(x) + exp(x)) / 2. 
x 
See also: cos, acos, sinh, tanh. 

curve (frame) 
Returns the y value of the animation curve at the given frame. 
optional: frame, defaults to current frame. 
See also: value, y. 

degrees (x) 
Convert the angle x from radians into degrees. 
x 
See also: radians. 

exp (x) 
Returns the value of e (the base of natural logarithms) raised to the power of x. 
x 
See also: log, log10. 

exponent (x) 
Exponent of x. 
x 
See also: mantissa, ldexp. 

fBm (x, y, z, octaves, lacunarity, gain) 
Fractional Brownian Motion. This is the sum of octaves calls to noise(). For each of them the input point is multiplied by pow(lacunarity,i) and the result is multiplied by pow(gain,i). For normal use, lacunarity should be greater than 1 and gain should be less than 1. 
x, y, z, octaves, lacunarity, gain 
See also: noise, random, turbulence. 

fabs (x) 
Returns the absolute value of the floatingpoint number x. 
x 
See also: abs. 

false () 
Always returns 0 
See also: true. 

floor (x) 
Round x down to the nearest integer. 
x 
See also: ceil, trunc, rint. 

fmod (x, y) 
Computes the remainder of dividing x by y. The return value is x – n y, where n is the quotient of x / y, rounded towards zero to an integer. 
x, y 
See also: ceil, floor. 

frame () 
Return the current frame number. 
See also: x. 

from_byte (color component) 
Converts an sRGB pixel value to a linear value. 
color_component 
See also: to_sRGB, to_rec709f, from_rec709f. 

from_rec709f (color component) 
Converts a rec709 byte value to a linear brightness 
color_component 
See also: form_sRGB, to_rec709f. 

from_sRGB (color component) 
Converts an sRGB pixel value to a linear value. 
color_component 
See also: to_sRGB, to_rec709f, from_rec709f. 

hypot (x, y) 
Returns the sqrt(x*x + y*y). This is the length of the hypotenuse of a rightangle triangle with sides of length x and y. 
x, y 
See also: atan2. 

int (x) 
Round x to the nearest integer not larger in absolute value. 
x 
See also: ceil, floor, trunc, rint. 

ldexp (x) 
Returns the result of multiplying the floatingpoint number x by 2 raised to the power exp. 
x, exp 
See also: exponent. 

lerp (a, b, x) 
Returns a point on the line f(x) where f(0)==a and f(1)==b. Matches the lerp function in other shading languages. 
a, b, x 
See also: step, smoothstep. 

log (x) 
Returns the natural logarithm of x. 
x 
See also: log10, exp. 

log10 (x) 
Returns the base10 logarithm of x. 
x 
See also: log, exp. 

logb (x) 
Same as exponent(). 
x 
See also: mantissa, exponent. 

mantissa (x) 
Returns the normalized fraction. If the argument x is not zero, the normalized fraction is x times a power of two, and is always in the range 1/2 (inclusive) to 1 (exclusive). If x is zero, then the normalized fraction is zero and exponent() Returns zero. 
x 
See also: exponent. 

max (x, y, … ) 
Return the greatest of all values. 
x, y, (…) 
See also: min, clamp. 

min (x, y, … ) 
Return the smallest of all values. 
x, y, (…) 
See also: max, clamp. 

mix (a, b, x) 
Same as lerp(). 
a, b, x 
See also: step, smoothstep, lerp. 

noise (x, y, z) 
Creates a 3D Perlin noise value. This produces a signed range centerd on zero. The absolute maximum range is from 1.0 to 1.0. This produces zero at all integers, so you should rotate the coordinates somewhat (add a fraction of y and z to x, etc.) if you want to use this for random number generation. 
x, optional y, optional z 
See also: random, fBm, turbulence. 

pi () 
Returns the value for pi (3.141592654…). 

pow (x, y) 
Returns the value of x raised to the power of y. 
x, y 
See also: log, exp, pow. 

pow2 (x) 
Returns the value of x raised to the power of 2. 
x, y 
See also: pow. 

radians (x) 
Convert the angle x from degrees into radians. 
x 
See also: degrees. 

random (x, y, z) 
Creates a pseudo random value between 0 and 1. It always generates the same value for the same x, y and z. Calling random with no arguments creates a different value on every invocation. 
optional x, optional y, optional z 
See also: noise, fBm, turbulence. 

rint (x) 
Round x to the nearest integer. 
x 
See also: ceil, floor, int, trunc. 

sin (x) 
Returns the sine of x. 
x in radians 
See also: asin, cos, tan, sinh. 

sinh (x) 
Returns the hyperbolic sine of x, which is defined mathematically as (exp(x) – exp(x)) / 2. 
x 
See also: sin, asin, cosh, tanh. 

smoothstep (a, b, x) 
Returns 0 if x is less than a, returns 1 if x is greater or equal to b, returns a smooth cubic interpolation otherwise. Matches the smoothstep function in other shading languages. 
a, b, x 
See also: step, lerp. 

sqrt (x) 
Returns the nonnegative square root of x. 
x 
See also: pow, pow2. 

step (a, x) 
Returns 0 if x is less than a, returns 1 otherwise. Matches the step function other shading languages. 
a, x 
See also: smoothstep, lerp. 

tan (x) 
Returns the tangent of x. 
x in radians 
See also: atan, cos, sin, tanh, atan2. 

tanh (x) 
Returns the hyperbolic tangent of x, which is defined mathematically as sinh(x) / cosh(x). 
x 
See also: tan, atan, sinh, cosh. 

to_byte (color component) 
Converts a floating point pixel value to an 8bit value that represents that number in sRGB space. 
color_component 
See also: form_sRGB, to_rec709f, from_rec709f. 

to_rec709f (color component) 
Converts a floating point pixel value to an 8bit value that represents that brightness in the rec709 standard when that standard is mapped to the 0255 range. 
color_component 
See also: form_sRGB, from_rec709f. 

to_sRGB (color component) 
Converts a floating point pixel value to an 8bit value that represents that number in sRGB space. 
color_component 
See also: form_sRGB, to_rec709f, from_rec709f. 

true () 
Always Returns 1. 
See also: false 

trunc (x) 
Round x to the nearest integer not larger in absolute value. 
x 
See also: ceil, floor, int, rint. 

turbulence (x, y, z, octaves, lucanarity, gain) 
This is the same as fBm() except the absolute value of the noise() function is used. 
x, y, z, octaves, lucanarity, gain 
See also: fBm, noise, random. 

value (frame) 
Evaluates the y value for an animation at the given frame. 
optional: frame, defaults to current frame. 
See also: y, curve. 

x () 
Return the current frame number. 
See also: frame. 

y (frame) 
Evaluates the y value for an animation at the given frame. 
optional: frame, defaults to current frame. 
See also: value, curve. 