-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython-basics.sw.yaml
More file actions
61 lines (52 loc) · 1.47 KB
/
Copy pathpython-basics.sw.yaml
File metadata and controls
61 lines (52 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
document:
dsl: '1.0.2'
namespace: examples
name: python-basics
version: '1.0.0'
description: |
Demonstrates basic Python script execution in jackdaw.
Shows how to use embedded Python to perform calculations
and data processing.
do:
- calculateFactorial:
run:
script:
language: python
arguments:
- "10"
code: |
import sys
import json
def factorial(n):
if n <= 1:
return 1
return n * factorial(n - 1)
n = int(sys.argv[1])
result = {
"input": n,
"factorial": factorial(n),
"message": f"The factorial of {n} is {factorial(n)}"
}
print(json.dumps(result))
output:
as:
calculateFactorial: ${ . }
- processData:
run:
script:
language: python
arguments:
- ${ .calculateFactorial.factorial | tostring }
code: |
import sys
import json
factorial_value = int(sys.argv[1])
# Demonstrate using Python libraries
import math
result = {
"factorial": factorial_value,
"log10": math.log10(factorial_value),
"sqrt": math.sqrt(factorial_value),
"formatted": f"{factorial_value:,}"
}
print(json.dumps(result))