Last active
September 18, 2021 18:16
-
-
Save wemakefuture/55608487840505d3e5aa195919aa3836 to your computer and use it in GitHub Desktop.
Examples for Integromat "Run your Python Code" module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Here you can find some basic examples for the /python api app/endpoint. | |
Keep in mind that you can insert Integromat variables into the text area. | |
To test code beforehand you can go to: https://www.programiz.com/python-programming/online-compiler/ | |
If you want to see the output that is shown about = the output the API gives you, you can just add after your code the following to see the output: | |
```python | |
import json | |
print(json.dumps(result)) | |
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def multiplyNumbers(number1, number2): | |
calculation = number1 * number2 | |
return calculation | |
result = { | |
"data": multiplyNumbers(43, 11) | |
} | |
# output: { result: { data: 473 } } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
array=numpy.random.randint(1000, size=(16)) | |
index = 0 | |
result ={} | |
for number in array: | |
result['randInt'+str(index)] = str(array[index]) | |
index+=1 | |
""" | |
output: { | |
result: { | |
randInt0: '819', | |
randInt1: '794', | |
randInt2: '181', | |
randInt3: '811', | |
randInt4: '205', | |
randInt5: '187', | |
randInt6: '697', | |
randInt7: '141', | |
randInt8: '479', | |
randInt9: '732', | |
randInt10: '360', | |
randInt11: '794', | |
randInt12: '648', | |
randInt13: '585', | |
randInt14: '171', | |
randInt15: '940' | |
} | |
} | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Hero: | |
def __init__(self, name, level): | |
self.name = name | |
self.level = level | |
def greet(self): | |
return self.name + " says hello." | |
class Mage(Hero): | |
def __init__(self, name, level, spell): | |
super().__init__(name, level) | |
# Add a new property | |
self.spell = spell | |
gandalf = Mage("Gandalf", 87, "You shall not pass!") | |
result = { | |
"name": gandalf.name, | |
"level": gandalf.level, | |
"spell": gandalf.spell, | |
"greet": gandalf.greet() | |
} | |
""" | |
output: | |
{ | |
result: { | |
name: 'Gandalf', | |
level: 87, | |
spell: 'You shall not pass!', | |
greet: 'Gandalf says hello.' | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment