Adding and Averaging Variables in Python.
Posted: Tue Jul 29, 2014 3:47 pm
So I've got some variable in Indigo, bring them into a Python script, and need to list them, add them, and average them, and send out via email. When I run the math part in Terminal, it works fine...
But the best I can get for adding them together in Indigo is not 1+2+3 = 6, but just the numbers sequentially - 123. And nothing I've tried for the average has worked. I have consulted this page
http://wiki.indigodomo.com/doku.php?id= ... g_tutorial
which was very helpful in getting just the listing and the emailing done properly, but don't see anything that relates to the math with the variables I'm trying to do here. I've listed a few of the things I've tried for both theSum and theAvg, but, as I said, so far, nothing.
I even tried for theSum using
Hoping this is an easy one to solve.....
This is the current script, with a few variations, which don't work..
- Code: Select all
>>> theVar1 = 1
>>> theVar2 = 2
>>> theVar3 = 3
>>> theSum = theVar1+theVar2+theVar3
>>> theAvg = theSum/3
>>>
>>> print theSum, theAvg
6 2
>>>
But the best I can get for adding them together in Indigo is not 1+2+3 = 6, but just the numbers sequentially - 123. And nothing I've tried for the average has worked. I have consulted this page
http://wiki.indigodomo.com/doku.php?id= ... g_tutorial
which was very helpful in getting just the listing and the emailing done properly, but don't see anything that relates to the math with the variables I'm trying to do here. I've listed a few of the things I've tried for both theSum and theAvg, but, as I said, so far, nothing.
I even tried for theSum using
- Code: Select all
theSum1 = indigo.variables[2343]+indigo.variables[45643]
Hoping this is an easy one to solve.....
This is the current script, with a few variations, which don't work..
- Code: Select all
# Listing variables, adding together, averaging, and emailing
theVar1 = indigo.variables[203610088]
theVar2 = indigo.variables[1949474627]
theVar3 = indigo.variables[1721091434]
theSum1 = (theVar1.value)+(theVar2.value)+(theVar3.value)
theSum2 = theVar1.value+theVar2.value+theVar3.value
theAvg1 = theSum1/3
theAvg2 = (theSum1)/3
theAvg3 = theSum1.value/3
theSubject = "Indigo Variables"
theBody = "The Variable #1 is %s\n The Variable #2 is %s\nThe Total is %s/n the Average is %s" % (theVar1.value, theVar2.value, theSum1, theAvg1)
indigo.server.sendEmailTo("jltnol@xyz.com", subject=theSubject, body=theBody)