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 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
[
  {
    "id": "lesson_1_variables",
    "gate": "Gate A — Fundamentals",
    "title": "1. Variables & Memory Assignment",
    "shortDescription": "Learn how programs name, store, and reuse values in memory.",
    "conceptExplanation": {
      "overview": "A variable is a named storage container in a computer's memory. Instead of re-typing numbers or text everywhere, you store a value once under a descriptive name (like 'user_age' or 'total_price') and pass it to other nodes.",
      "keyPoints": [
        "In Python, assignment uses '=': variable_name = value.",
        "Variable names must start with a letter or underscore, not a number.",
        "Wiring a variable into another node passes its stored value across the wire."
      ],
      "whyItMatters": "Without variables, programs could not remember user inputs or calculate dynamic results.",
      "pythonCode": "# Python Variable Assignment\nuser_age = 25\nprint(f\"Age stored: {user_age}\")"
    },
    "guidedSteps": [
      {
        "stepNumber": 1,
        "title": "Create a Variable",
        "instruction": "Add a Variable node or Constant Number node to the canvas.",
        "conceptNote": "This allocates a piece of memory for your program.",
        "pythonStatement": "score = 100"
      },
      {
        "stepNumber": 2,
        "title": "Assign a Name and Value",
        "instruction": "Set the variable identifier to 'score' and value to 100 in the Configuration Drawer.",
        "conceptNote": "Names should be lowercase with underscores (PEP 8 convention).",
        "pythonStatement": "# score is now 100"
      },
      {
        "stepNumber": 3,
        "title": "Read the Output",
        "instruction": "Connect the variable output to a Print node and run to verify the output.",
        "conceptNote": "Data flows out of the right port into downstream nodes.",
        "pythonStatement": "print(score)"
      }
    ],
    "starterGraph": {
      "name": "Lesson 1 Starter",
      "nodes": [
        {
          "id": "score_var",
          "node_type": "alli.primitive.variable",
          "position": {
            "x": 100,
            "y": 160
          },
          "data": {
            "label": "score",
            "customData": {
              "var_name": "score",
              "value": 100,
              "type_hint": "int"
            }
          }
        },
        {
          "id": "print_node",
          "node_type": "alli.primitive.print",
          "position": {
            "x": 420,
            "y": 160
          },
          "data": {
            "label": "Print Result",
            "customData": {
              "prefix": ""
            }
          }
        }
      ],
      "edges": []
    },
    "exercise": {
      "type": "build_graph",
      "prompt": "Build a workflow that declares a variable or constant named 'score' with value 100, and connect it to a Print node.",
      "targetRequirements": {
        "requiredNodeTypes": [
          "variable",
          "constant",
          "print"
        ],
        "requiredEdgeCount": 1,
        "expectedTargetOutput": {
          "portId": "result",
          "expectedValue": 100
        }
      },
      "hints": [
        "Drag a Number Constant or Variable node onto the canvas.",
        "Open its inspector to set the value to 100.",
        "Connect its output port to a Print node's input port."
      ],
      "solutionExplanation": "The variable stores 100 in memory and passes it across the wire to the Print node, outputting 100."
    }
  },
  {
    "id": "lesson_2_data_types",
    "gate": "Gate A — Fundamentals",
    "title": "2. Data Types & Type Conversion",
    "shortDescription": "Understand Strings vs Integers and learn how to convert between them.",
    "conceptExplanation": {
      "overview": "Every value in Python has a data type. '42' (text string) is NOT the same as 42 (integer). If you try to add text to a number, Python raises a TypeError. You must convert ('cast') text to an integer before doing math.",
      "keyPoints": [
        "int: whole numbers like 10, -5, 42.",
        "float: decimal numbers like 3.14, 99.9.",
        "str: text wrapped in quotes like 'Hello'.",
        "bool: True or False decisions."
      ],
      "whyItMatters": "Web forms and APIs return data as text strings. Converting them to integers lets you calculate totals and verify conditions.",
      "pythonCode": "# Type Conversion in Python\nraw_input = \"42\"        # str\nnumber = int(raw_input) # converted to int\ntotal = number + 8      # 50"
    },
    "guidedSteps": [
      {
        "stepNumber": 1,
        "title": "Recognize Text Strings",
        "instruction": "Notice how text in quotes like '10' is treated as text characters, not a quantity.",
        "conceptNote": "In Python: '10' + '20' equals '1020' (concatenation), not 30!",
        "pythonStatement": "text_val = \"42\""
      },
      {
        "stepNumber": 2,
        "title": "Use Type Conversion",
        "instruction": "Use a Type Conversion node to turn a string into an integer.",
        "conceptNote": "int('42') parses the string characters into a numeric integer.",
        "pythonStatement": "parsed = int(\"42\")"
      },
      {
        "stepNumber": 3,
        "title": "Perform Arithmetic",
        "instruction": "Connect the converted integer into an Add node to compute math.",
        "conceptNote": "Now 42 + 8 correctly calculates 50.",
        "pythonStatement": "result = parsed + 8"
      }
    ],
    "starterGraph": {
      "name": "String Concat Quiz Graph",
      "nodes": [
        {
          "id": "s1",
          "node_type": "constant.str",
          "position": {
            "x": 100,
            "y": 120
          },
          "data": {
            "label": "Str1",
            "customData": {
              "var_name": "str_1",
              "value": "10"
            }
          }
        },
        {
          "id": "s2",
          "node_type": "constant.str",
          "position": {
            "x": 100,
            "y": 240
          },
          "data": {
            "label": "Str2",
            "customData": {
              "var_name": "str_2",
              "value": "20"
            }
          }
        },
        {
          "id": "op",
          "node_type": "core.binary_op",
          "position": {
            "x": 380,
            "y": 180
          },
          "data": {
            "label": "Add",
            "customData": {
              "var_name": "concat_res",
              "operator": "+"
            }
          }
        }
      ],
      "edges": [
        {
          "id": "e1",
          "source": "s1",
          "target": "op",
          "target_handle": "a"
        },
        {
          "id": "e2",
          "source": "s2",
          "target": "op",
          "target_handle": "b"
        }
      ]
    },
    "exercise": {
      "type": "predict_output",
      "question": "In Python and ALLI, what does \"10\" + \"20\" evaluate to if both values are Strings?",
      "graph": {
        "name": "String Concat Quiz",
        "nodes": [
          {
            "id": "s1",
            "node_type": "constant.str",
            "position": {
              "x": 100,
              "y": 120
            },
            "data": {
              "label": "Str1",
              "customData": {
                "var_name": "str_1",
                "value": "10"
              }
            }
          },
          {
            "id": "s2",
            "node_type": "constant.str",
            "position": {
              "x": 100,
              "y": 240
            },
            "data": {
              "label": "Str2",
              "customData": {
                "var_name": "str_2",
                "value": "20"
              }
            }
          },
          {
            "id": "op",
            "node_type": "core.binary_op",
            "position": {
              "x": 380,
              "y": 180
            },
            "data": {
              "label": "Add",
              "customData": {
                "var_name": "concat_res",
                "operator": "+"
              }
            }
          }
        ],
        "edges": [
          {
            "id": "e1",
            "source": "s1",
            "target": "op",
            "target_handle": "a"
          },
          {
            "id": "e2",
            "source": "s2",
            "target": "op",
            "target_handle": "b"
          }
        ]
      },
      "options": [
        {
          "label": "30 (Integer)",
          "value": "30",
          "isCorrect": false,
          "explanation": "Incorrect: String '+' concatenates text without mathematical addition."
        },
        {
          "label": "\"1020\" (String)",
          "value": "1020",
          "isCorrect": true,
          "explanation": "Correct! When '+' is used on strings, Python joins the characters into '1020'."
        },
        {
          "label": "TypeError Error",
          "value": "error",
          "isCorrect": false,
          "explanation": "Incorrect: String concatenation is valid in Python."
        },
        {
          "label": "0 (Undefined)",
          "value": "0",
          "isCorrect": false,
          "explanation": "Incorrect: '10' and '20' are valid string literals."
        }
      ]
    }
  },
  {
    "id": "lesson_3_arithmetic",
    "gate": "Gate A — Fundamentals",
    "title": "3. Arithmetic Operators & Division Safety",
    "shortDescription": "Calculate sums, products, and handle division-by-zero errors safely.",
    "conceptExplanation": {
      "overview": "Arithmetic nodes perform calculations on numbers. Dividing by zero is mathematically impossible and will halt programs with a ZeroDivisionError unless handled properly.",
      "keyPoints": [
        "+: Addition (10 + 20 = 30)",
        "*: Multiplication (10 * 2 = 20)",
        "/: True division producing float (10 / 2 = 5.0)",
        "//: Floor integer division (7 // 2 = 3)",
        "**: Power / Exponent (2 ** 8 = 256)"
      ],
      "whyItMatters": "Every business rule, pricing calculation, and physics simulation relies on arithmetic operators.",
      "pythonCode": "# Arithmetic in Python\nprice = 100\ndiscount = 20\nfinal_price = price - discount # 80"
    },
    "guidedSteps": [
      {
        "stepNumber": 1,
        "title": "Connect Numbers to Operators",
        "instruction": "Feed operand A and operand B into the binary operation node.",
        "conceptNote": "Both inputs must receive data before the node can execute.",
        "pythonStatement": "result = a + b"
      },
      {
        "stepNumber": 2,
        "title": "Choose the Operator",
        "instruction": "Select +, -, *, /, or ** in the operator dropdown.",
        "conceptNote": "Changing operators instantly updates the live preview.",
        "pythonStatement": "power_result = 2 ** 8 # 256"
      },
      {
        "stepNumber": 3,
        "title": "Handle Division by Zero",
        "instruction": "If input B is 0 with '/' operator, ALLI gives structured recovery advice: change B to non-zero.",
        "conceptNote": "Zero division cannot produce a real number.",
        "pythonStatement": "try:\n    res = 10 / 0\nexcept ZeroDivisionError:\n    print('Cannot divide by zero!')"
      }
    ],
    "starterGraph": {
      "name": "Broken Div Graph",
      "nodes": [
        {
          "id": "n_num",
          "node_type": "constant.int",
          "position": {
            "x": 100,
            "y": 120
          },
          "data": {
            "label": "Numerator",
            "customData": {
              "var_name": "numerator",
              "value": 100
            }
          }
        },
        {
          "id": "n_denom",
          "node_type": "constant.int",
          "position": {
            "x": 100,
            "y": 240
          },
          "data": {
            "label": "Denominator",
            "customData": {
              "var_name": "denominator",
              "value": 0
            }
          }
        },
        {
          "id": "n_div",
          "node_type": "core.binary_op",
          "position": {
            "x": 380,
            "y": 180
          },
          "data": {
            "label": "Divide",
            "customData": {
              "var_name": "div_res",
              "operator": "/"
            }
          }
        }
      ],
      "edges": [
        {
          "id": "e1",
          "source": "n_num",
          "target": "n_div",
          "target_handle": "a"
        },
        {
          "id": "e2",
          "source": "n_denom",
          "target": "n_div",
          "target_handle": "b"
        }
      ]
    },
    "exercise": {
      "type": "debug_fix",
      "prompt": "This workflow is failing because it attempts to divide 100 by 0. Fix the denominator node to 5 so the result calculates 20.",
      "brokenGraph": {
        "name": "Broken Div Graph",
        "nodes": [
          {
            "id": "n_num",
            "node_type": "constant.int",
            "position": {
              "x": 100,
              "y": 120
            },
            "data": {
              "label": "Numerator",
              "customData": {
                "var_name": "numerator",
                "value": 100
              }
            }
          },
          {
            "id": "n_denom",
            "node_type": "constant.int",
            "position": {
              "x": 100,
              "y": 240
            },
            "data": {
              "label": "Denominator",
              "customData": {
                "var_name": "denominator",
                "value": 0
              }
            }
          },
          {
            "id": "n_div",
            "node_type": "core.binary_op",
            "position": {
              "x": 380,
              "y": 180
            },
            "data": {
              "label": "Divide",
              "customData": {
                "var_name": "div_res",
                "operator": "/"
              }
            }
          }
        ],
        "edges": [
          {
            "id": "e1",
            "source": "n_num",
            "target": "n_div",
            "target_handle": "a"
          },
          {
            "id": "e2",
            "source": "n_denom",
            "target": "n_div",
            "target_handle": "b"
          }
        ]
      },
      "bugDescription": "Denominator node currently holds value 0, causing division by zero error (ERR-DIV-ZERO).",
      "fixCriteria": {
        "expectedStatus": "success",
        "expectedTargetOutput": {
          "nodeId": "n_div",
          "expectedValue": 20
        }
      },
      "hints": [
        "Select the 'Denominator' node on canvas.",
        "Open its configuration drawer.",
        "Change the value from 0 to 5.",
        "Click 'Check My Work' or Run Flow to verify."
      ],
      "solutionExplanation": "Changing the denominator to 5 allows 100 / 5 = 20 to compute cleanly without zero division."
    }
  },
  {
    "id": "lesson_4_comparisons",
    "gate": "Gate A — Fundamentals",
    "title": "4. Relational Comparisons",
    "shortDescription": "Compare values with ==, !=, <, <=, >, >= to produce Boolean decisions.",
    "conceptExplanation": {
      "overview": "Relational operators compare two values and return either True or False. For example, comparing if a user's age is greater than or equal to 18 (age >= 18) outputs True for an adult.",
      "keyPoints": [
        "==: Equal to",
        "!=: Not equal to",
        ">: Greater than",
        ">=: Greater than or equal to",
        "<: Less than",
        "<=: Less than or equal to"
      ],
      "whyItMatters": "Comparisons form the foundation of decision making in programs. Without comparisons, code could not branch.",
      "pythonCode": "# Relational Comparisons in Python\nage = 20\nis_adult = (age >= 18) # True\nprint(f\"Is adult: {is_adult}\")"
    },
    "guidedSteps": [
      {
        "stepNumber": 1,
        "title": "Input Values to Compare",
        "instruction": "Connect two number nodes into Value A and Value B ports.",
        "conceptNote": "Comparisons take two operands of compatible types.",
        "pythonStatement": "is_pass = score >= 50"
      },
      {
        "stepNumber": 2,
        "title": "Select Comparison Operator",
        "instruction": "Select '>=' to check if A reaches or exceeds the threshold B.",
        "conceptNote": "If A = 30 and B = 25, 30 >= 25 is True.",
        "pythonStatement": "30 >= 25 # True"
      }
    ],
    "starterGraph": {
      "name": "Lesson 4 Starter",
      "nodes": [
        {
          "id": "c1",
          "node_type": "constant.int",
          "position": {
            "x": 100,
            "y": 120
          },
          "data": {
            "label": "ValA",
            "customData": {
              "var_name": "val_a",
              "value": 35
            }
          }
        },
        {
          "id": "c2",
          "node_type": "constant.int",
          "position": {
            "x": 100,
            "y": 240
          },
          "data": {
            "label": "ValB",
            "customData": {
              "var_name": "val_b",
              "value": 25
            }
          }
        },
        {
          "id": "cmp",
          "node_type": "core.compare",
          "position": {
            "x": 380,
            "y": 180
          },
          "data": {
            "label": "Compare",
            "customData": {
              "var_name": "cmp_res",
              "operator": ">="
            }
          }
        }
      ],
      "edges": []
    },
    "exercise": {
      "type": "build_graph",
      "prompt": "Build a comparison workflow: Connect a constant with value 35 and a threshold constant with value 25 to a Compare node (>=). Verify it outputs True.",
      "targetRequirements": {
        "requiredNodeTypes": [
          "constant",
          "compare"
        ],
        "requiredEdgeCount": 2,
        "expectedTargetOutput": {
          "portId": "result",
          "expectedValue": true
        }
      },
      "hints": [
        "Add two Number Constant nodes (35 and 25).",
        "Add a Compare Values node.",
        "Set the comparison operator to '>='.",
        "Connect 35 to port 'a' and 25 to port 'b'."
      ],
      "solutionExplanation": "35 is greater than 25, so the Compare node's output port emits Boolean True."
    }
  },
  {
    "id": "lesson_5_boolean_logic",
    "gate": "Gate A — Fundamentals",
    "title": "5. Boolean Logic (AND, OR, NOT)",
    "shortDescription": "Combine multiple conditions into compound decisions.",
    "conceptExplanation": {
      "overview": "Boolean operators combine true/false values. AND requires both sides to be True. OR requires at least one side to be True. NOT inverts the condition.",
      "keyPoints": [
        "AND: True only if BOTH conditions are True (True and False = False).",
        "OR: True if EITHER condition is True (False or True = True).",
        "NOT: Inverts truth value (not True = False)."
      ],
      "whyItMatters": "Real-world rules require multiple criteria: e.g. (has_ticket AND is_on_time) or (is_vip).",
      "pythonCode": "# Boolean Logic in Python\nhas_ticket = True\nis_vip = False\ncan_enter = has_ticket or is_vip # True"
    },
    "guidedSteps": [
      {
        "stepNumber": 1,
        "title": "Understand AND",
        "instruction": "AND requires all inputs to be True. If any input is False, the result is False.",
        "conceptNote": "True and True is True; True and False is False.",
        "pythonStatement": "valid = (age >= 18) and has_id"
      },
      {
        "stepNumber": 2,
        "title": "Understand OR",
        "instruction": "OR succeeds as long as at least one input is True.",
        "conceptNote": "False or True is True; False or False is False.",
        "pythonStatement": "discount = is_student or is_senior"
      }
    ],
    "starterGraph": {
      "name": "Compound Logic Quiz Graph",
      "nodes": [
        {
          "id": "b1",
          "node_type": "constant.bool",
          "position": {
            "x": 80,
            "y": 100
          },
          "data": {
            "label": "BoolA",
            "customData": {
              "var_name": "b_1",
              "value": true
            }
          }
        },
        {
          "id": "b2",
          "node_type": "constant.bool",
          "position": {
            "x": 80,
            "y": 190
          },
          "data": {
            "label": "BoolB",
            "customData": {
              "var_name": "b_2",
              "value": false
            }
          }
        },
        {
          "id": "and_op",
          "node_type": "core.logical_op",
          "position": {
            "x": 280,
            "y": 140
          },
          "data": {
            "label": "AndOp",
            "customData": {
              "var_name": "and_res",
              "operator": "and"
            }
          }
        },
        {
          "id": "b3",
          "node_type": "constant.bool",
          "position": {
            "x": 280,
            "y": 240
          },
          "data": {
            "label": "BoolC",
            "customData": {
              "var_name": "b_3",
              "value": true
            }
          }
        },
        {
          "id": "or_op",
          "node_type": "core.logical_op",
          "position": {
            "x": 480,
            "y": 180
          },
          "data": {
            "label": "OrOp",
            "customData": {
              "var_name": "or_res",
              "operator": "or"
            }
          }
        }
      ],
      "edges": [
        {
          "id": "e1",
          "source": "b1",
          "target": "and_op",
          "target_handle": "a"
        },
        {
          "id": "e2",
          "source": "b2",
          "target": "and_op",
          "target_handle": "b"
        },
        {
          "id": "e3",
          "source": "and_op",
          "target": "or_op",
          "target_handle": "a"
        },
        {
          "id": "e4",
          "source": "b3",
          "target": "or_op",
          "target_handle": "b"
        }
      ]
    },
    "exercise": {
      "type": "predict_output",
      "question": "What is the result of: (True AND False) OR True?",
      "graph": {
        "name": "Compound Logic Quiz",
        "nodes": [
          {
            "id": "b1",
            "node_type": "constant.bool",
            "position": {
              "x": 80,
              "y": 100
            },
            "data": {
              "label": "BoolA",
              "customData": {
                "var_name": "b_1",
                "value": true
              }
            }
          },
          {
            "id": "b2",
            "node_type": "constant.bool",
            "position": {
              "x": 80,
              "y": 190
            },
            "data": {
              "label": "BoolB",
              "customData": {
                "var_name": "b_2",
                "value": false
              }
            }
          },
          {
            "id": "and_op",
            "node_type": "core.logical_op",
            "position": {
              "x": 280,
              "y": 140
            },
            "data": {
              "label": "AndOp",
              "customData": {
                "var_name": "and_res",
                "operator": "and"
              }
            }
          },
          {
            "id": "b3",
            "node_type": "constant.bool",
            "position": {
              "x": 280,
              "y": 240
            },
            "data": {
              "label": "BoolC",
              "customData": {
                "var_name": "b_3",
                "value": true
              }
            }
          },
          {
            "id": "or_op",
            "node_type": "core.logical_op",
            "position": {
              "x": 480,
              "y": 180
            },
            "data": {
              "label": "OrOp",
              "customData": {
                "var_name": "or_res",
                "operator": "or"
              }
            }
          }
        ],
        "edges": [
          {
            "id": "e1",
            "source": "b1",
            "target": "and_op",
            "target_handle": "a"
          },
          {
            "id": "e2",
            "source": "b2",
            "target": "and_op",
            "target_handle": "b"
          },
          {
            "id": "e3",
            "source": "and_op",
            "target": "or_op",
            "target_handle": "a"
          },
          {
            "id": "e4",
            "source": "b3",
            "target": "or_op",
            "target_handle": "b"
          }
        ]
      },
      "options": [
        {
          "label": "True (Boolean)",
          "value": "true",
          "isCorrect": true,
          "explanation": "Correct! True AND False evaluates to False. Then False OR True evaluates to True."
        },
        {
          "label": "False (Boolean)",
          "value": "false",
          "isCorrect": false,
          "explanation": "Incorrect: The right-hand operand of the OR is True, making the final result True."
        },
        {
          "label": "None / Null",
          "value": "null",
          "isCorrect": false,
          "explanation": "Incorrect: Boolean expressions always resolve to True or False."
        }
      ]
    }
  },
  {
    "id": "lesson_6_if_else",
    "gate": "Gate B — Decisions",
    "title": "6. Conditional Branching (If / Else)",
    "shortDescription": "Direct execution down distinct paths and isolate unselected branches.",
    "conceptExplanation": {
      "overview": "An If/Else node evaluates an incoming Boolean condition. When the condition is True, only the 'Then' branch runs. When False, only the 'Else' branch runs. The inactive branch is marked 'skipped' and produces zero errors.",
      "keyPoints": [
        "If True: activates Then output port.",
        "If False: activates Else output port.",
        "Inactive branches are safely isolated without crashing downstream logic."
      ],
      "whyItMatters": "Conditionals give programs intelligence to adapt to different users, errors, and data states.",
      "pythonCode": "# Conditional Branching in Python\nage = 20\nif age >= 18:\n    message = \"Welcome Adult\"\nelse:\n    message = \"Welcome Minor\""
    },
    "guidedSteps": [
      {
        "stepNumber": 1,
        "title": "Provide Condition",
        "instruction": "Wire a Boolean comparison or constant into the 'condition' port.",
        "conceptNote": "The condition decides which pathway executes.",
        "pythonStatement": "if condition:"
      },
      {
        "stepNumber": 2,
        "title": "Wire Then & Else Outputs",
        "instruction": "Connect the 'then' port to the success action, and 'else' port to the fallback action.",
        "conceptNote": "Only the selected branch runs; the other is skipped.",
        "pythonStatement": "    do_then_action()\nelse:\n    do_else_action()"
      }
    ],
    "starterGraph": {
      "name": "Lesson 6 Starter",
      "nodes": [
        {
          "id": "c_cond",
          "node_type": "constant.bool",
          "position": {
            "x": 80,
            "y": 160
          },
          "data": {
            "label": "Condition",
            "customData": {
              "var_name": "cond",
              "value": true
            }
          }
        },
        {
          "id": "branch_node",
          "node_type": "control.if_else",
          "position": {
            "x": 320,
            "y": 160
          },
          "data": {
            "label": "IfElse",
            "customData": {
              "var_name": "branch",
              "condition": true
            }
          }
        },
        {
          "id": "p_then",
          "node_type": "alli.primitive.print",
          "position": {
            "x": 560,
            "y": 100
          },
          "data": {
            "label": "PrintPass",
            "customData": {
              "var_name": "print_pass",
              "value": "Pass",
              "prefix": ""
            }
          }
        },
        {
          "id": "p_else",
          "node_type": "alli.primitive.print",
          "position": {
            "x": 560,
            "y": 240
          },
          "data": {
            "label": "PrintFail",
            "customData": {
              "var_name": "print_fail",
              "value": "Fail",
              "prefix": ""
            }
          }
        }
      ],
      "edges": []
    },
    "exercise": {
      "type": "build_graph",
      "prompt": "Build an If/Else flow: Connect a Boolean constant (True) to an If/Else node. Wire 'then' to a Print node ('Pass') and 'else' to a Print node ('Fail'). Run to verify 'Pass' executes and 'Fail' is skipped.",
      "targetRequirements": {
        "requiredNodeTypes": [
          "constant",
          "if_else",
          "print"
        ],
        "requiredEdgeCount": 3,
        "expectedTargetOutput": {
          "portId": "result",
          "expectedValue": "Pass"
        }
      },
      "hints": [
        "Add a Boolean Constant set to True.",
        "Add an If / Else Branching node.",
        "Add two Print nodes: one with 'Pass' and one with 'Fail'.",
        "Wire True to condition, 'then' to Pass, 'else' to Fail."
      ],
      "solutionExplanation": "Because the condition is True, the Then branch executes 'Pass' and the Else branch is cleanly skipped."
    }
  },
  {
    "id": "lesson_7_for_loops",
    "gate": "Gate C — Repetition",
    "title": "7. For Loops & Bounded Sequences",
    "shortDescription": "Iterate over a sequence or count of items in a deterministic order.",
    "conceptExplanation": {
      "overview": "A For Loop iterates over each item in a collection or range of numbers. Unlike uncontrolled while loops, a for loop is naturally bounded because it visits each element in a sequence exactly once.",
      "keyPoints": [
        "In Python, 'for item in range(count):' runs count times (from 0 to count - 1).",
        "The iteration variable ('item') holds the value of the current cycle.",
        "The 'collected' output contains the complete list of elements traversed."
      ],
      "whyItMatters": "Iterating over collections of data is foundational to batch processing, aggregations, and data pipelines.",
      "pythonCode": "# For Loop in Python\ncollected = []\nfor i in range(5):\n    collected.append(i)\nprint(collected)  # [0, 1, 2, 3, 4]"
    },
    "guidedSteps": [
      {
        "stepNumber": 1,
        "title": "Add a For Loop",
        "instruction": "Drag a For Loop node onto the canvas from the Control Flow category.",
        "conceptNote": "By default, it iterates over range(0, range_count).",
        "pythonStatement": "for item in range(5):"
      },
      {
        "stepNumber": 2,
        "title": "Inspect Parameters",
        "instruction": "Open the configuration drawer and set Range Count to 5.",
        "conceptNote": "Range Count sets how many iterations will run.",
        "pythonStatement": "# range_count = 5"
      },
      {
        "stepNumber": 3,
        "title": "Output Collected Items",
        "instruction": "Connect the 'collected' or 'result' port to a Print node and click Run Flow.",
        "conceptNote": "The output emits [0, 1, 2, 3, 4] with iteration_count = 5.",
        "pythonStatement": "print(collected)"
      }
    ],
    "starterGraph": {
      "name": "Lesson 7 Starter",
      "nodes": [
        {
          "id": "loop_node",
          "node_type": "control.for_loop",
          "position": {
            "x": 120,
            "y": 160
          },
          "data": {
            "label": "ForLoop",
            "customData": {
              "var_name": "for_loop",
              "iterator_var": "i",
              "range_count": 5
            }
          }
        },
        {
          "id": "p_node",
          "node_type": "alli.primitive.print",
          "position": {
            "x": 440,
            "y": 160
          },
          "data": {
            "label": "PrintList",
            "customData": {
              "var_name": "print_list",
              "prefix": ""
            }
          }
        }
      ],
      "edges": []
    },
    "exercise": {
      "type": "build_graph",
      "prompt": "Build a For Loop flow: Connect the For Loop node (range_count=5) to the Print node. Run to verify 5 items are generated.",
      "targetRequirements": {
        "requiredNodeTypes": [
          "for_loop",
          "print"
        ],
        "requiredEdgeCount": 1,
        "expectedTargetOutput": {
          "portId": "iteration_count",
          "expectedValue": 5
        }
      },
      "hints": [
        "Drag a connection wire from the 'collected' or 'result' port of ForLoop to PrintList.",
        "Ensure the loop node has range_count set to 5."
      ],
      "solutionExplanation": "The For Loop node generates 5 integers (0 through 4) and emits the collected list to the print node."
    }
  },
  {
    "id": "lesson_8_while_loops",
    "gate": "Gate C — Repetition",
    "title": "8. While Loops & State Termination",
    "shortDescription": "Repeat execution while a condition remains True, bounded by a safety cap.",
    "conceptExplanation": {
      "overview": "A While Loop executes repeatedly as long as its continuation condition remains True. In ALLI, all while loops are protected by a strict max_iterations safety cap (default: 100) to ensure accidental infinite loops never freeze the system.",
      "keyPoints": [
        "The continuation condition is re-evaluated before each cycle.",
        "The state counter must be incremented in each cycle to make progress toward termination.",
        "The max_iterations safety cap prevents runaway cycles."
      ],
      "whyItMatters": "While loops allow algorithms to run until a specific target threshold or convergence condition is satisfied.",
      "pythonCode": "# Bounded While Loop in Python\ncount = 0\nmax_iter = 100\nwhile count < 5 and count < max_iter:\n    count += 1\nprint(count)  # 5"
    },
    "guidedSteps": [
      {
        "stepNumber": 1,
        "title": "Add a While Loop",
        "instruction": "Add a While Loop node to the canvas.",
        "conceptNote": "Defaults to starting at 0, stepping by 1, with threshold 5.",
        "pythonStatement": "while count < 5:"
      },
      {
        "stepNumber": 2,
        "title": "Configure Threshold",
        "instruction": "Set initial_value to 0, step_value to 1, and target_threshold to 5.",
        "conceptNote": "In each step: count += 1 until count reaches 5.",
        "pythonStatement": "    count += 1"
      },
      {
        "stepNumber": 3,
        "title": "Connect and Run",
        "instruction": "Connect the While Loop output to a Print node and run to verify it reaches 5.",
        "conceptNote": "The final result is 5 across 5 iterations.",
        "pythonStatement": "print(count)"
      }
    ],
    "starterGraph": {
      "name": "Lesson 8 Starter",
      "nodes": [
        {
          "id": "while_node",
          "node_type": "control.while_loop",
          "position": {
            "x": 120,
            "y": 160
          },
          "data": {
            "label": "WhileLoop",
            "customData": {
              "var_name": "while_loop",
              "initial_value": 0,
              "step_value": 1,
              "target_threshold": 5
            }
          }
        },
        {
          "id": "p_node",
          "node_type": "alli.primitive.print",
          "position": {
            "x": 440,
            "y": 160
          },
          "data": {
            "label": "PrintCount",
            "customData": {
              "var_name": "print_count",
              "prefix": ""
            }
          }
        }
      ],
      "edges": []
    },
    "exercise": {
      "type": "build_graph",
      "prompt": "Build a While Loop: Connect the WhileLoop node (initial=0, threshold=5, step=1) to the Print node. Run to verify it terminates with result 5.",
      "targetRequirements": {
        "requiredNodeTypes": [
          "while_loop",
          "print"
        ],
        "requiredEdgeCount": 1,
        "expectedTargetOutput": {
          "portId": "result",
          "expectedValue": 5
        }
      },
      "hints": [
        "Connect the output of the While Loop to the Print node.",
        "Check that the threshold is set to 5 and step is 1."
      ],
      "solutionExplanation": "The while loop starts at 0 and increments by 1 on each iteration, terminating when count equals 5."
    }
  },
  {
    "id": "lesson_9_loop_control",
    "gate": "Gate C — Repetition",
    "title": "9. Loop Control (Break & Continue)",
    "shortDescription": "Prematurely exit a loop or skip iterations using explicit control statements.",
    "conceptExplanation": {
      "overview": "The 'break' statement terminates the loop immediately, stopping all further iterations. The 'continue' statement skips the remaining steps of the current iteration and jumps directly to the next cycle.",
      "keyPoints": [
        "'break' immediately exits the loop block.",
        "'continue' skips only the remainder of the current iteration.",
        "Both statements require a conditional check (like 'if count == 3: break')."
      ],
      "whyItMatters": "Early exits prevent wasted computation when searching for an element or when an error condition occurs.",
      "pythonCode": "# Loop Control in Python\nfor i in range(10):\n    if i == 3:\n        break\nprint(i)  # 3"
    },
    "guidedSteps": [
      {
        "stepNumber": 1,
        "title": "Understand Early Exit",
        "instruction": "When a target value is reached, break exits the loop without visiting remaining items.",
        "conceptNote": "Stops unnecessary work.",
        "pythonStatement": "if item == target:\n    break"
      },
      {
        "stepNumber": 2,
        "title": "Understand Skip (Continue)",
        "instruction": "When an element should be ignored (e.g. negative numbers), continue skips to the next item.",
        "conceptNote": "Skips remaining code in current cycle.",
        "pythonStatement": "if item < 0:\n    continue"
      }
    ],
    "starterGraph": {
      "name": "Break Concept Graph",
      "nodes": [
        {
          "id": "for_node",
          "node_type": "control.for_loop",
          "position": {
            "x": 100,
            "y": 150
          },
          "data": {
            "label": "ForLoop",
            "customData": {
              "var_name": "for_10",
              "range_count": 10
            }
          }
        },
        {
          "id": "ctrl_node",
          "node_type": "control.loop_control",
          "position": {
            "x": 350,
            "y": 150
          },
          "data": {
            "label": "LoopControl",
            "customData": {
              "var_name": "ctrl",
              "action": "break"
            }
          }
        }
      ],
      "edges": []
    },
    "exercise": {
      "type": "predict_output",
      "question": "If a loop iterates over range(10) [0 through 9] and executes 'if i == 3: break', what is the final value of i?",
      "graph": {
        "name": "Break Prediction Graph",
        "nodes": [
          {
            "id": "loop_10",
            "node_type": "control.for_loop",
            "position": {
              "x": 100,
              "y": 120
            },
            "data": {
              "label": "Loop10",
              "customData": {
                "var_name": "loop",
                "range_count": 10
              }
            }
          },
          {
            "id": "ctrl_break",
            "node_type": "control.loop_control",
            "position": {
              "x": 350,
              "y": 120
            },
            "data": {
              "label": "BreakAt3",
              "customData": {
                "var_name": "brk",
                "action": "break"
              }
            }
          }
        ],
        "edges": []
      },
      "options": [
        {
          "label": "3",
          "value": "3",
          "isCorrect": true,
          "explanation": "Correct! The loop visits 0, 1, 2, and then upon reaching 3, the break statement terminates the loop immediately."
        },
        {
          "label": "10",
          "value": "10",
          "isCorrect": false,
          "explanation": "Incorrect: The loop does not run to completion because the break statement terminates it at 3."
        },
        {
          "label": "9",
          "value": "9",
          "isCorrect": false,
          "explanation": "Incorrect: 9 would be the last index if the loop was uninterrupted, but break stopped it at 3."
        }
      ]
    }
  },
  {
    "id": "lesson_10_loop_debugging",
    "gate": "Gate C — Repetition",
    "title": "10. Loop Debugging & Off-by-One Errors",
    "shortDescription": "Diagnose and fix off-by-one boundary bugs and infinite loop traps.",
    "conceptExplanation": {
      "overview": "The off-by-one error is one of the most common programming bugs. In Python, range(N) produces numbers from 0 to N-1 (N elements in total). Another common bug is forgetting to increment a counter in a while loop, which triggers the safety iteration limit.",
      "keyPoints": [
        "range(5) produces [0, 1, 2, 3, 4] — exactly 5 elements.",
        "range(4) produces only 4 elements: [0, 1, 2, 3].",
        "If an exercise requires 5 iterations, range_count must be set to 5."
      ],
      "whyItMatters": "Off-by-one errors lead to missing data, incorrect sums, and index-out-of-bounds errors in production systems.",
      "pythonCode": "# Correcting an Off-by-One Bug\n# Buggy: range(4) has only 4 elements\n# Correct: range(5) has 5 elements (0, 1, 2, 3, 4)\ncorrect_range = range(5)\nprint(len(list(correct_range)))  # 5"
    },
    "guidedSteps": [
      {
        "stepNumber": 1,
        "title": "Identify Missing Item",
        "instruction": "Notice the broken loop is configured with range_count = 4, producing only 4 items instead of the required 5.",
        "conceptNote": "Boundary error: missing the 5th item.",
        "pythonStatement": "# range(4) != range(5)"
      },
      {
        "stepNumber": 2,
        "title": "Fix the Range Count",
        "instruction": "Select the ForLoop node and change Range Count from 4 to 5.",
        "conceptNote": "Fixes the boundary condition.",
        "pythonStatement": "for i in range(5):"
      },
      {
        "stepNumber": 3,
        "title": "Re-run and Verify",
        "instruction": "Run the workflow to verify iteration_count equals 5.",
        "conceptNote": "The fix resolves the bug and produces the target output.",
        "pythonStatement": "assert len(collected) == 5"
      }
    ],
    "starterGraph": {
      "name": "Broken Loop Graph",
      "nodes": [
        {
          "id": "buggy_loop",
          "node_type": "control.for_loop",
          "position": {
            "x": 120,
            "y": 160
          },
          "data": {
            "label": "ForLoop",
            "customData": {
              "var_name": "buggy_loop",
              "range_count": 4
            }
          }
        },
        {
          "id": "p_node",
          "node_type": "alli.primitive.print",
          "position": {
            "x": 440,
            "y": 160
          },
          "data": {
            "label": "PrintResult",
            "customData": {
              "var_name": "print_res",
              "prefix": ""
            }
          }
        }
      ],
      "edges": [
        {
          "id": "e1",
          "source": "buggy_loop",
          "target": "p_node",
          "target_handle": "value"
        }
      ]
    },
    "exercise": {
      "type": "debug_fix",
      "prompt": "This loop was configured with range_count=4 and only produces 4 iterations instead of the required 5. Fix the range_count parameter on ForLoop to 5 to pass.",
      "brokenGraph": {
        "name": "Broken Loop Graph",
        "nodes": [
          {
            "id": "buggy_loop",
            "node_type": "control.for_loop",
            "position": {
              "x": 120,
              "y": 160
            },
            "data": {
              "label": "ForLoop",
              "customData": {
                "var_name": "buggy_loop",
                "range_count": 4
              }
            }
          },
          {
            "id": "p_node",
            "node_type": "alli.primitive.print",
            "position": {
              "x": 440,
              "y": 160
            },
            "data": {
              "label": "PrintResult",
              "customData": {
                "var_name": "print_res",
                "prefix": ""
              }
            }
          }
        ],
        "edges": [
          {
            "id": "e1",
            "source": "buggy_loop",
            "target": "p_node",
            "target_handle": "value"
          }
        ]
      },
      "bugDescription": "ForLoop currently has range_count=4, producing only 4 items instead of 5.",
      "fixCriteria": {
        "expectedStatus": "success",
        "expectedTargetOutput": {
          "nodeId": "buggy_loop",
          "portId": "iteration_count",
          "expectedValue": 5
        }
      },
      "hints": [
        "Select the ForLoop node on the canvas.",
        "Change range_count from 4 to 5 in the configuration drawer.",
        "Run the flow to verify that 5 iterations are executed."
      ],
      "solutionExplanation": "Changing range_count to 5 generates 5 iterations (0, 1, 2, 3, 4), satisfying the requirement and fixing the off-by-one error."
    }
  },
  {
    "id": "lesson_11_function_defs",
    "gate": "Gate D — Functions & Scope",
    "title": "11. Function Definitions: Packaging Reusable Logic",
    "shortDescription": "Define functions using def, named parameters, and return expressions.",
    "conceptExplanation": {
      "overview": "Functions are named blocks of code that perform a specific task. Defining a function packages logic into a reusable unit that can be called whenever needed with different inputs.",
      "keyPoints": [
        "def keyword starts a function definition in Python.",
        "Parameters act as placeholders for values passed into the function.",
        "The return statement sends the calculated result back to the caller.",
        "Docstrings document what the function does and what inputs it expects."
      ],
      "whyItMatters": "Without functions, programs would require copying and pasting identical code everywhere, making maintenance difficult and error-prone.",
      "pythonCode": "def double_it(x):\n    \"\"\"Multiply the input by two.\"\"\"\n    return x * 2\n\nresult = double_it(21)  # 42"
    },
    "guidedSteps": [
      {
        "stepNumber": 1,
        "title": "Declare Function Name & Parameters",
        "instruction": "Set the function name to 'double_it' and parameter to 'x'.",
        "conceptNote": "Function names should be descriptive snake_case identifiers.",
        "pythonStatement": "def double_it(x):"
      },
      {
        "stepNumber": 2,
        "title": "Define the Return Expression",
        "instruction": "Set the return expression to 'x * 2'.",
        "conceptNote": "The return expression computes the output value produced when the function runs.",
        "pythonStatement": "    return x * 2"
      },
      {
        "stepNumber": 3,
        "title": "Add Documentation",
        "instruction": "Write a concise docstring explaining what the function returns.",
        "conceptNote": "Docstrings help other developers understand the function's contract.",
        "pythonStatement": "    \"\"\"Multiply input by two.\"\"\""
      }
    ],
    "starterGraph": {
      "name": "Function Def Starter",
      "nodes": [
        {
          "id": "fn_double",
          "node_type": "function.def",
          "position": {
            "x": 140,
            "y": 160
          },
          "data": {
            "label": "DoubleItDef",
            "customData": {
              "func_name": "double_it",
              "params": "x",
              "return_expr": "x * 2",
              "docstring": "Multiply the input by two"
            }
          }
        }
      ],
      "edges": []
    },
    "exercise": {
      "type": "predict_output",
      "question": "In Python and ALLI, if double_it(x) is defined with return expression 'x * 2', what does double_it(25) return?",
      "graph": {
        "name": "DoubleIt Quiz Graph",
        "nodes": [
          {
            "id": "fn_def",
            "node_type": "function.def",
            "position": {
              "x": 120,
              "y": 140
            },
            "data": {
              "label": "DoubleDef",
              "customData": {
                "func_name": "double_it",
                "params": "x",
                "return_expr": "x * 2"
              }
            }
          },
          {
            "id": "call_quiz",
            "node_type": "function.call",
            "position": {
              "x": 420,
              "y": 140
            },
            "data": {
              "label": "DoubleCall",
              "customData": {
                "func_name": "double_it",
                "arg_val": 25
              }
            }
          }
        ],
        "edges": [
          {
            "id": "e1",
            "source": "fn_def",
            "target": "call_quiz",
            "source_handle": "func_ref",
            "target_handle": "func_in"
          }
        ]
      },
      "options": [
        {
          "label": "50",
          "value": "50",
          "isCorrect": true,
          "explanation": "Correct! double_it(25) evaluates 25 * 2 = 50."
        },
        {
          "label": "25",
          "value": "25",
          "isCorrect": false,
          "explanation": "Incorrect: The function doubles the input."
        },
        {
          "label": "2525",
          "value": "2525",
          "isCorrect": false,
          "explanation": "Incorrect: The input is a numeric integer, not a string."
        },
        {
          "label": "None",
          "value": "None",
          "isCorrect": false,
          "explanation": "Incorrect: The function has a return expression."
        }
      ]
    }
  },
  {
    "id": "lesson_12_function_calls",
    "gate": "Gate D — Functions & Scope",
    "title": "12. Function Calls: Passing Arguments & Receiving Results",
    "shortDescription": "Invoke defined functions by passing arguments and receiving return values.",
    "conceptExplanation": {
      "overview": "Calling a function executes its packaged logic with concrete argument values and returns the computed result back into the workflow.",
      "keyPoints": [
        "Arguments provide concrete values to substitute for the function's parameter variables.",
        "A function call suspends the caller, creates a new local execution frame, and returns a value.",
        "Return values can be wired to other nodes, printed, or stored in variables."
      ],
      "whyItMatters": "Function calls allow complex computations to be abstracted into single intelligible steps.",
      "pythonCode": "def square(n):\n    return n * n\n\narea = square(6)  # 36"
    },
    "guidedSteps": [
      {
        "stepNumber": 1,
        "title": "Connect Function Reference",
        "instruction": "Wire func_ref from Function Definition to func_in on Function Call.",
        "conceptNote": "This links the call node to the specific function implementation.",
        "pythonStatement": "# Function reference wired"
      },
      {
        "stepNumber": 2,
        "title": "Pass Arguments",
        "instruction": "Wire a Constant Integer node into the argument input port.",
        "conceptNote": "The argument value is passed into parameter 'x'.",
        "pythonStatement": "result = double_it(21)"
      },
      {
        "stepNumber": 3,
        "title": "Inspect the Result",
        "instruction": "Run the workflow and check the Function Call output port 'result'.",
        "conceptNote": "The calculated return value (42) is now available for downstream nodes.",
        "pythonStatement": "print(result) # 42"
      }
    ],
    "starterGraph": {
      "name": "Function Call Starter",
      "nodes": [
        {
          "id": "fn_node",
          "node_type": "function.def",
          "position": {
            "x": 100,
            "y": 120
          },
          "data": {
            "label": "DoubleDef",
            "customData": {
              "func_name": "double_it",
              "params": "x",
              "return_expr": "x * 2"
            }
          }
        },
        {
          "id": "arg_node",
          "node_type": "constant.int",
          "position": {
            "x": 100,
            "y": 260
          },
          "data": {
            "label": "Arg21",
            "customData": {
              "var_name": "arg_val",
              "value": 21
            }
          }
        },
        {
          "id": "call_node",
          "node_type": "function.call",
          "position": {
            "x": 380,
            "y": 180
          },
          "data": {
            "label": "DoubleCall",
            "customData": {
              "func_name": "double_it"
            }
          }
        }
      ],
      "edges": [
        {
          "id": "e1",
          "source": "fn_node",
          "target": "call_node",
          "source_handle": "func_ref",
          "target_handle": "func_in"
        },
        {
          "id": "e2",
          "source": "arg_node",
          "target": "call_node",
          "target_handle": "arg"
        }
      ]
    },
    "exercise": {
      "type": "build_graph",
      "prompt": "Construct a workflow with a Function Definition for 'double_it' (x * 2), a Constant Integer 21, and a Function Call node. Connect the constant into the Function Call so it produces 42.",
      "targetRequirements": {
        "requiredNodeTypes": [
          "function.def",
          "constant.int",
          "function.call"
        ],
        "requiredEdgeCount": 2,
        "expectedTargetOutput": {
          "portId": "result",
          "expectedValue": 42
        }
      },
      "hints": [
        "Add a Function Definition node and set func_name to 'double_it' and return_expr to 'x * 2'.",
        "Add a Constant Integer node and set its value to 21.",
        "Add a Function Call node and wire the constant into its argument input.",
        "Run the flow to verify that result equals 42."
      ],
      "solutionExplanation": "The Function Definition specifies double_it(x) = x * 2. Passing 21 into the call node evaluates 21 * 2 = 42."
    }
  },
  {
    "id": "lesson_13_variable_scope",
    "gate": "Gate D — Functions & Scope",
    "title": "13. Variable Scope: Local Isolation & Scope Boundaries",
    "shortDescription": "Understand local variables inside functions vs global variables on the canvas.",
    "conceptExplanation": {
      "overview": "Variables defined inside a function belong to its local scope. They cannot be seen outside the function, and modifying them does not change global variables with the same name.",
      "keyPoints": [
        "Local Scope: variables created inside a function exist only during the function's execution.",
        "Global Scope: variables defined at the top level of the canvas or module.",
        "Name Shadowing: a local parameter 'x' shadows global 'x' inside the function without modifying the global 'x'.",
        "Encapsulation prevents accidental side-effects and bugs in large programs."
      ],
      "whyItMatters": "Scope isolation ensures functions are safe to use anywhere without worrying that internal variable names will corrupt the rest of your program.",
      "pythonCode": "x = 100  # Global variable\n\ndef modify(x):\n    x = 999  # Local parameter\n    return x\n\nprint(modify(50))  # 999\nprint(x)           # Still 100!"
    },
    "guidedSteps": [
      {
        "stepNumber": 1,
        "title": "Inspect Global Variable",
        "instruction": "Create a global variable 'x' set to 100.",
        "conceptNote": "Global variables are accessible throughout the main workflow.",
        "pythonStatement": "x = 100  # Global scope"
      },
      {
        "stepNumber": 2,
        "title": "Execute Local Function",
        "instruction": "Call a function that accepts parameter 'x' and computes 'x * 2'.",
        "conceptNote": "Inside the function, 'x' refers to the local argument, not the global variable.",
        "pythonStatement": "result = modify(50)  # Local x = 50"
      },
      {
        "stepNumber": 3,
        "title": "Verify Scope Isolation",
        "instruction": "Check the global variable 'x' to confirm it remains 100.",
        "conceptNote": "Local execution frames protect global state from unintended mutation.",
        "pythonStatement": "assert x == 100  # Scope preserved"
      }
    ],
    "starterGraph": {
      "name": "Scope Isolation Starter",
      "nodes": [
        {
          "id": "glob_x",
          "node_type": "alli.primitive.variable",
          "position": {
            "x": 100,
            "y": 120
          },
          "data": {
            "label": "GlobalVarX",
            "customData": {
              "var_name": "x",
              "value": 100
            }
          }
        },
        {
          "id": "fn_scope",
          "node_type": "function.def",
          "position": {
            "x": 100,
            "y": 260
          },
          "data": {
            "label": "ModifyDef",
            "customData": {
              "func_name": "modify",
              "params": "x",
              "return_expr": "x * 2"
            }
          }
        },
        {
          "id": "call_scope",
          "node_type": "function.call",
          "position": {
            "x": 380,
            "y": 260
          },
          "data": {
            "label": "ModifyCall",
            "customData": {
              "func_name": "modify",
              "arg_val": 50
            }
          }
        },
        {
          "id": "scope_insp",
          "node_type": "core.scope",
          "position": {
            "x": 380,
            "y": 120
          },
          "data": {
            "label": "ScopeInspector",
            "customData": {
              "var_name": "x",
              "scope_type": "global"
            }
          }
        }
      ],
      "edges": [
        {
          "id": "e1",
          "source": "fn_scope",
          "target": "call_scope",
          "source_handle": "func_ref",
          "target_handle": "func_in"
        }
      ]
    },
    "exercise": {
      "type": "predict_output",
      "question": "A global variable 'x' is set to 100. A function 'modify(x)' runs with argument 50 and returns 100. What is the value of the global variable 'x' after the function executes?",
      "graph": {
        "name": "Scope Quiz Graph",
        "nodes": [
          {
            "id": "glob_x",
            "node_type": "alli.primitive.variable",
            "position": {
              "x": 100,
              "y": 120
            },
            "data": {
              "label": "GlobalVarX",
              "customData": {
                "var_name": "x",
                "value": 100
              }
            }
          },
          {
            "id": "fn_scope",
            "node_type": "function.def",
            "position": {
              "x": 100,
              "y": 260
            },
            "data": {
              "label": "ModifyDef",
              "customData": {
                "func_name": "modify",
                "params": "x",
                "return_expr": "x * 2"
              }
            }
          }
        ],
        "edges": []
      },
      "options": [
        {
          "label": "100 (Unchanged)",
          "value": "100",
          "isCorrect": true,
          "explanation": "Correct! Function parameters are local to the function frame and never mutate global variables."
        },
        {
          "label": "50",
          "value": "50",
          "isCorrect": false,
          "explanation": "Incorrect: 50 was the local argument passed into the function."
        },
        {
          "label": "0",
          "value": "0",
          "isCorrect": false,
          "explanation": "Incorrect: The global variable retains its assigned value 100."
        },
        {
          "label": "None",
          "value": "None",
          "isCorrect": false,
          "explanation": "Incorrect: Variable 'x' is initialized to 100."
        }
      ]
    }
  },
  {
    "id": "lesson_14_reusable_logic",
    "gate": "Gate D — Functions & Scope",
    "title": "14. Modular Reusability: Multiple Calls, Clean Pipelines",
    "shortDescription": "Reuse a single function definition across multiple distinct call nodes (DRY Principle).",
    "conceptExplanation": {
      "overview": "The DRY (Don't Repeat Yourself) principle states that every piece of logic must have a single representation in a system. Defining a function once allows it to be invoked with multiple different inputs throughout the pipeline.",
      "keyPoints": [
        "Write Once, Run Many: write a calculation once and reuse it across multiple data points.",
        "Single Source of Truth: if the formula needs to change, update only the function definition.",
        "Composability: function outputs can be combined, added, or passed into other functions."
      ],
      "whyItMatters": "Reusability is the foundation of clean software architecture. It reduces code bloat, simplifies testing, and prevents copy-paste bugs.",
      "pythonCode": "def double_it(x):\n    return x * 2\n\nval_a = double_it(15)  # 30\nval_b = double_it(35)  # 70\ntotal = val_a + val_b  # 100"
    },
    "guidedSteps": [
      {
        "stepNumber": 1,
        "title": "Define the Core Logic",
        "instruction": "Create a single Function Definition node for 'double_it' with return 'x * 2'.",
        "conceptNote": "This acts as the single source of truth for the doubling formula.",
        "pythonStatement": "def double_it(x):\n    return x * 2"
      },
      {
        "stepNumber": 2,
        "title": "Invoke with First Input",
        "instruction": "Create a Function Call node with argument 15 (evaluates to 30).",
        "conceptNote": "The first call executes independently in its own frame.",
        "pythonStatement": "val_a = double_it(15)  # 30"
      },
      {
        "stepNumber": 3,
        "title": "Invoke with Second Input",
        "instruction": "Create a second Function Call node with argument 35 (evaluates to 70).",
        "conceptNote": "Both call nodes reference the same function definition.",
        "pythonStatement": "val_b = double_it(35)  # 70"
      },
      {
        "stepNumber": 4,
        "title": "Combine Results",
        "instruction": "Add the two call outputs together in a Binary Operation node to produce 100.",
        "conceptNote": "Composing modular function outputs creates elegant, readable workflows.",
        "pythonStatement": "total = val_a + val_b  # 100"
      }
    ],
    "starterGraph": {
      "name": "Modular Reusability Starter",
      "nodes": [
        {
          "id": "fn_shared",
          "node_type": "function.def",
          "position": {
            "x": 80,
            "y": 160
          },
          "data": {
            "label": "DoubleItDef",
            "customData": {
              "func_name": "double_it",
              "params": "x",
              "return_expr": "x * 2"
            }
          }
        },
        {
          "id": "c1",
          "node_type": "constant.int",
          "position": {
            "x": 260,
            "y": 100
          },
          "data": {
            "label": "Num15",
            "customData": {
              "value": 15
            }
          }
        },
        {
          "id": "call_1",
          "node_type": "function.call",
          "position": {
            "x": 440,
            "y": 100
          },
          "data": {
            "label": "Call1",
            "customData": {
              "func_name": "double_it"
            }
          }
        },
        {
          "id": "c2",
          "node_type": "constant.int",
          "position": {
            "x": 260,
            "y": 240
          },
          "data": {
            "label": "Num35",
            "customData": {
              "value": 35
            }
          }
        },
        {
          "id": "call_2",
          "node_type": "function.call",
          "position": {
            "x": 440,
            "y": 240
          },
          "data": {
            "label": "Call2",
            "customData": {
              "func_name": "double_it"
            }
          }
        },
        {
          "id": "add_totals",
          "node_type": "core.binary_op",
          "position": {
            "x": 680,
            "y": 170
          },
          "data": {
            "label": "SumTotals",
            "customData": {
              "operator": "+"
            }
          }
        }
      ],
      "edges": [
        {
          "id": "e1",
          "source": "fn_shared",
          "target": "call_1",
          "source_handle": "func_ref",
          "target_handle": "func_in"
        },
        {
          "id": "e2",
          "source": "c1",
          "target": "call_1",
          "target_handle": "arg"
        },
        {
          "id": "e3",
          "source": "fn_shared",
          "target": "call_2",
          "source_handle": "func_ref",
          "target_handle": "func_in"
        },
        {
          "id": "e4",
          "source": "c2",
          "target": "call_2",
          "target_handle": "arg"
        },
        {
          "id": "e5",
          "source": "call_1",
          "target": "add_totals",
          "source_handle": "result",
          "target_handle": "a"
        },
        {
          "id": "e6",
          "source": "call_2",
          "target": "add_totals",
          "source_handle": "result",
          "target_handle": "b"
        }
      ]
    },
    "exercise": {
      "type": "debug_fix",
      "prompt": "The second function call's input constant is incorrectly set to 10 instead of 35, yielding 50 instead of 100. Fix constant node 'c2' to 35 so double_it(15) + double_it(35) = 100.",
      "brokenGraph": {
        "name": "Broken Reusability Graph",
        "nodes": [
          {
            "id": "fn_shared",
            "node_type": "function.def",
            "position": {
              "x": 80,
              "y": 160
            },
            "data": {
              "label": "DoubleItDef",
              "customData": {
                "func_name": "double_it",
                "params": "x",
                "return_expr": "x * 2"
              }
            }
          },
          {
            "id": "c1",
            "node_type": "constant.int",
            "position": {
              "x": 260,
              "y": 100
            },
            "data": {
              "label": "Num15",
              "customData": {
                "value": 15
              }
            }
          },
          {
            "id": "call_1",
            "node_type": "function.call",
            "position": {
              "x": 440,
              "y": 100
            },
            "data": {
              "label": "Call1",
              "customData": {
                "func_name": "double_it"
              }
            }
          },
          {
            "id": "c2",
            "node_type": "constant.int",
            "position": {
              "x": 260,
              "y": 240
            },
            "data": {
              "label": "NumBuggy",
              "customData": {
                "value": 10
              }
            }
          },
          {
            "id": "call_2",
            "node_type": "function.call",
            "position": {
              "x": 440,
              "y": 240
            },
            "data": {
              "label": "Call2",
              "customData": {
                "func_name": "double_it"
              }
            }
          },
          {
            "id": "add_totals",
            "node_type": "core.binary_op",
            "position": {
              "x": 680,
              "y": 170
            },
            "data": {
              "label": "SumTotals",
              "customData": {
                "operator": "+"
              }
            }
          }
        ],
        "edges": [
          {
            "id": "e1",
            "source": "fn_shared",
            "target": "call_1",
            "source_handle": "func_ref",
            "target_handle": "func_in"
          },
          {
            "id": "e2",
            "source": "c1",
            "target": "call_1",
            "target_handle": "arg"
          },
          {
            "id": "e3",
            "source": "fn_shared",
            "target": "call_2",
            "source_handle": "func_ref",
            "target_handle": "func_in"
          },
          {
            "id": "e4",
            "source": "c2",
            "target": "call_2",
            "target_handle": "arg"
          },
          {
            "id": "e5",
            "source": "call_1",
            "target": "add_totals",
            "source_handle": "result",
            "target_handle": "a"
          },
          {
            "id": "e6",
            "source": "call_2",
            "target": "add_totals",
            "source_handle": "result",
            "target_handle": "b"
          }
        ]
      },
      "bugDescription": "Constant node 'c2' has value 10, producing double_it(10) = 20, so total is 30 + 20 = 50 instead of 100.",
      "fixCriteria": {
        "expectedStatus": "success",
        "expectedTargetOutput": {
          "nodeId": "add_totals",
          "portId": "result",
          "expectedValue": 100
        }
      },
      "hints": [
        "Select constant node 'c2' (NumBuggy) on the canvas.",
        "Change its value from 10 to 35 in the configuration drawer.",
        "Run the flow to verify that double_it(15) + double_it(35) = 30 + 70 = 100."
      ],
      "solutionExplanation": "Changing c2 to 35 ensures double_it(35) returns 70. Combining 30 + 70 calculates the required sum of 100."
    }
  },
  {
    "id": "lesson_15_lists",
    "gate": "Gate E — Data Structures",
    "title": "Lists & Dynamic Sequences",
    "shortDescription": "Create ordered collections, append elements dynamically, and access items using zero-based indexing.",
    "conceptExplanation": {
      "overview": "Lists are ordered, mutable sequences of values. In Python, lists are declared with square brackets `[10, 20, 30]`. Elements are indexed starting from 0, and new items can be added dynamically using `.append()`.",
      "keyPoints": [
        "Zero-based indexing: The first item is at index `0`, second at `1`, and negative indices like `-1` access from the end.",
        "Mutable sequence: Elements can be added with `.append()`, modified in place, or removed.",
        "Length calculation: The built-in `len(my_list)` function returns the count of items in the list.",
        "Linear dataflow: Downstream nodes can iterate through a list or pull specific values."
      ],
      "whyItMatters": "Lists are the backbone of program data storage, allowing workflows to handle collections of records, batch events, and variable series in a single variable.",
      "pythonCode": "items = [10, 20, 30]\nitems.append(40)\nfirst = items[0]\ncount = len(items)\nprint(f\"Items: {items}, First: {first}, Total: {count}\")"
    },
    "guidedSteps": [
      {
        "stepNumber": 1,
        "title": "Create Initial List",
        "instruction": "Add a List node ('data.list') and configure 'initial_items' with '[10, 20, 30]'.",
        "conceptNote": "Lists preserve item order and allow duplicate elements.",
        "nodeToInspect": "my_list",
        "pythonStatement": "my_list = [10, 20, 30]"
      },
      {
        "stepNumber": 2,
        "title": "Append an Element",
        "instruction": "Connect a Constant node with value '40' to the 'item' input and set operation to 'append'.",
        "conceptNote": ".append() increases the list length by 1 and places the new element at the end.",
        "nodeToInspect": "my_list",
        "pythonStatement": "my_list.append(40)"
      },
      {
        "stepNumber": 3,
        "title": "Inspect Outputs",
        "instruction": "Run the flow and inspect output ports: 'result' evaluates to '[10, 20, 30, 40]' and 'length' evaluates to 4.",
        "conceptNote": "Downstream nodes can read the entire collection or access individual elements by index.",
        "pythonStatement": "print(len(my_list))"
      }
    ],
    "starterGraph": {
      "name": "List Operations Starter Graph",
      "nodes": [
        {
          "id": "list_node",
          "node_type": "data.list",
          "position": {
            "x": 100,
            "y": 150
          },
          "data": {
            "label": "NumbersList",
            "customData": {
              "operation": "append",
              "initial_items": "[10, 20, 30]"
            }
          }
        },
        {
          "id": "item_node",
          "node_type": "constant.int",
          "position": {
            "x": 100,
            "y": 280
          },
          "data": {
            "label": "NewItem",
            "customData": {
              "value": 40
            }
          }
        },
        {
          "id": "print_node",
          "node_type": "io.print",
          "position": {
            "x": 380,
            "y": 200
          },
          "data": {
            "label": "PrintList"
          }
        }
      ],
      "edges": [
        {
          "id": "e1",
          "source": "item_node",
          "target": "list_node",
          "target_handle": "item"
        },
        {
          "id": "e2",
          "source": "list_node",
          "target": "print_node",
          "source_handle": "result",
          "target_handle": "value"
        }
      ]
    },
    "exercise": {
      "type": "predict_output",
      "question": "If a List node starts with '[10, 20, 30]', appends '40', and inspects index 0, what are the values of 'length' and 'item'?",
      "graph": {
        "name": "List Predict Graph",
        "nodes": [
          {
            "id": "l1",
            "node_type": "data.list",
            "position": {
              "x": 100,
              "y": 100
            },
            "data": {
              "label": "TestList",
              "customData": {
                "operation": "append",
                "initial_items": "[10, 20, 30]",
                "index": 0
              }
            }
          },
          {
            "id": "c1",
            "node_type": "constant.int",
            "position": {
              "x": 100,
              "y": 220
            },
            "data": {
              "label": "AddVal",
              "customData": {
                "value": 40
              }
            }
          }
        ],
        "edges": [
          {
            "id": "e1",
            "source": "c1",
            "target": "l1",
            "target_handle": "item"
          }
        ]
      },
      "options": [
        {
          "label": "length = 4, item = 10",
          "value": "len_4_item_10",
          "isCorrect": true,
          "explanation": "Appending 40 expands the list from 3 to 4 elements. The element at 0-based index 0 is 10."
        },
        {
          "label": "length = 3, item = 20",
          "value": "len_3_item_20",
          "isCorrect": false,
          "explanation": "Appending an element increases the length to 4, not 3."
        },
        {
          "label": "length = 4, item = 40",
          "value": "len_4_item_40",
          "isCorrect": false,
          "explanation": "40 is at index 3 (the end of the list), while index 0 holds 10."
        },
        {
          "label": "length = 3, item = 10",
          "value": "len_3_item_10",
          "isCorrect": false,
          "explanation": "The list has 4 elements after appending 40."
        }
      ]
    }
  },
  {
    "id": "lesson_16_dictionaries",
    "gate": "Gate E — Data Structures",
    "title": "Dictionaries & Key-Value Mappings",
    "shortDescription": "Store structured records with unique keys, perform O(1) lookups, and update entries dynamically.",
    "conceptExplanation": {
      "overview": "Dictionaries (hash maps) store associative data in key-value pairs: `{'key': 'value'}`. Instead of accessing items by index number, values are queried using expressive identifiers, offering lightning-fast O(1) lookup times.",
      "keyPoints": [
        "Keys must be unique and hashable (strings, numbers, tuples).",
        "Lookup with `.get(key, default)` returns the value safely without raising KeyError if the key is missing.",
        "Dynamic updates: assigning `dict[key] = value` modifies an existing entry or creates a new one.",
        "Inspection: `.keys()` extracts all dictionary keys; `.values()` extracts all associated data."
      ],
      "whyItMatters": "Most software interfaces, JSON payloads, and user databases represent entities as dictionaries (e.g. user profiles, API responses, configuration files).",
      "pythonCode": "user = {\"name\": \"Alice\", \"role\": \"Engineer\"}\nuser[\"status\"] = \"Active\"\nrole = user.get(\"role\", \"N/A\")\nprint(f\"Role: {role}, Keys: {list(user.keys())}\")"
    },
    "guidedSteps": [
      {
        "stepNumber": 1,
        "title": "Create Dictionary",
        "instruction": "Add a Dictionary node ('data.dict') with initial dict '{\"name\": \"Alice\", \"role\": \"Engineer\"}'.",
        "conceptNote": "JSON syntax maps string keys to corresponding attribute values.",
        "nodeToInspect": "my_dict",
        "pythonStatement": "user = {\"name\": \"Alice\", \"role\": \"Engineer\"}"
      },
      {
        "stepNumber": 2,
        "title": "Query by Key",
        "instruction": "Set operation to 'get' and query_key to 'role'.",
        "conceptNote": "Dictionary lookup runs in O(1) average time complexity.",
        "nodeToInspect": "my_dict",
        "pythonStatement": "role = user.get(\"role\", \"N/A\")"
      },
      {
        "stepNumber": 3,
        "title": "Verify Output",
        "instruction": "Run the flow and verify output 'val' yields 'Engineer'.",
        "conceptNote": "Output port 'keys' also emits ['name', 'role'].",
        "pythonStatement": "print(user[\"role\"])"
      }
    ],
    "starterGraph": {
      "name": "Dictionary Lookup Starter Graph",
      "nodes": [
        {
          "id": "dict_node",
          "node_type": "data.dict",
          "position": {
            "x": 120,
            "y": 150
          },
          "data": {
            "label": "UserProfile",
            "customData": {
              "operation": "get",
              "initial_dict": "{\"name\": \"Alice\", \"role\": \"Engineer\"}",
              "query_key": "role"
            }
          }
        },
        {
          "id": "print_node",
          "node_type": "io.print",
          "position": {
            "x": 400,
            "y": 150
          },
          "data": {
            "label": "PrintRole"
          }
        }
      ],
      "edges": [
        {
          "id": "e1",
          "source": "dict_node",
          "target": "print_node",
          "source_handle": "val",
          "target_handle": "value"
        }
      ]
    },
    "exercise": {
      "type": "build_graph",
      "prompt": "Create a Dictionary node with initial dictionary '{\"status\": \"active\", \"code\": 200}', configure query_key to 'status', and wire output 'val' to an Output / Print node.",
      "targetRequirements": {
        "requiredNodeTypes": [
          "data.dict",
          "io.print"
        ],
        "requiredEdgeCount": 1,
        "expectedTargetOutput": {
          "portId": "val",
          "expectedValue": "active"
        }
      },
      "hints": [
        "Drag a Dictionary node ('data.dict') onto the canvas.",
        "Set operation to 'get' and query_key to 'status'.",
        "Wire the Dictionary's 'val' output into an Output / Print node."
      ],
      "solutionExplanation": "The Dictionary node queries 'status' from the initial dictionary and outputs 'active' to the Print node."
    }
  },
  {
    "id": "lesson_17_tuples",
    "gate": "Gate E — Data Structures",
    "title": "Tuples & Sequence Unpacking",
    "shortDescription": "Protect data against accidental modification with immutable tuples and unpack coordinates simultaneously.",
    "conceptExplanation": {
      "overview": "Tuples are ordered collections declared with parentheses `(10, 20)`. Unlike lists, tuples are immutable—once created, elements cannot be modified, added, or removed. Tuples also support simultaneous multi-variable unpacking.",
      "keyPoints": [
        "Immutable: Protects data integrity against unintended side-effects or mutations.",
        "Unpacking: Simultaneous assignment `(x, y) = point` extracts elements directly into distinct variables.",
        "Multiple returns: Functions often return multiple values bundled together inside a tuple.",
        "Memory efficiency: Tuples require less memory overhead than dynamic lists."
      ],
      "whyItMatters": "Immutability provides functional safety in distributed pipelines, coordinates, configuration pairs, and multi-value returns.",
      "pythonCode": "point = (100, 250)\nx, y = point\nprint(f\"X: {x}, Y: {y}, Count: {len(point)}\")"
    },
    "guidedSteps": [
      {
        "stepNumber": 1,
        "title": "Define Tuple",
        "instruction": "Add a Tuple node ('data.tuple') with elements '(100, 250)'.",
        "conceptNote": "Tuples group related values together into a fixed unit.",
        "nodeToInspect": "coords",
        "pythonStatement": "point = (100, 250)"
      },
      {
        "stepNumber": 2,
        "title": "Unpack Components",
        "instruction": "Set operation to 'unpack' to expose individual elements on output ports 'item_1' and 'item_2'.",
        "conceptNote": "Python tuple unpacking assigns variables simultaneously without temporary holding variables.",
        "nodeToInspect": "coords",
        "pythonStatement": "x, y = point"
      },
      {
        "stepNumber": 3,
        "title": "Run and Inspect",
        "instruction": "Run the flow and verify 'item_1' = 100, 'item_2' = 250, and 'length' = 2.",
        "conceptNote": "Attempting to reassign an element of a tuple in Python throws a TypeError.",
        "pythonStatement": "print(x, y)"
      }
    ],
    "starterGraph": {
      "name": "Tuple Unpacking Starter Graph",
      "nodes": [
        {
          "id": "tuple_node",
          "node_type": "data.tuple",
          "position": {
            "x": 120,
            "y": 150
          },
          "data": {
            "label": "Point2D",
            "customData": {
              "operation": "unpack",
              "elements": "(100, 250)"
            }
          }
        },
        {
          "id": "print_x",
          "node_type": "io.print",
          "position": {
            "x": 380,
            "y": 100
          },
          "data": {
            "label": "PrintX"
          }
        },
        {
          "id": "print_y",
          "node_type": "io.print",
          "position": {
            "x": 380,
            "y": 220
          },
          "data": {
            "label": "PrintY"
          }
        }
      ],
      "edges": [
        {
          "id": "e1",
          "source": "tuple_node",
          "target": "print_x",
          "source_handle": "item_1",
          "target_handle": "value"
        },
        {
          "id": "e2",
          "source": "tuple_node",
          "target": "print_y",
          "source_handle": "item_2",
          "target_handle": "value"
        }
      ]
    },
    "exercise": {
      "type": "predict_output",
      "question": "A Tuple node packs elements '(100, 250)' and unpacks them. What will output ports 'item_1' and 'item_2' emit?",
      "graph": {
        "name": "Tuple Predict Graph",
        "nodes": [
          {
            "id": "t1",
            "node_type": "data.tuple",
            "position": {
              "x": 100,
              "y": 100
            },
            "data": {
              "label": "CoordTuple",
              "customData": {
                "operation": "unpack",
                "elements": "(100, 250)"
              }
            }
          }
        ],
        "edges": []
      },
      "options": [
        {
          "label": "item_1 = 100, item_2 = 250",
          "value": "item1_100_item2_250",
          "isCorrect": true,
          "explanation": "Tuple unpacking maps the first element (100) to item_1 and the second (250) to item_2."
        },
        {
          "label": "item_1 = 250, item_2 = 100",
          "value": "item1_250_item2_100",
          "isCorrect": false,
          "explanation": "Tuples preserve strict positional order; 100 is first and 250 is second."
        },
        {
          "label": "item_1 = [100, 250], item_2 = null",
          "value": "item1_list_item2_null",
          "isCorrect": false,
          "explanation": "Unpacking separates elements into distinct output ports rather than keeping them grouped."
        },
        {
          "label": "item_1 = (100, 250), item_2 = 2",
          "value": "item1_tuple_item2_len",
          "isCorrect": false,
          "explanation": "item_1 unpacks the first scalar value (100), not the entire tuple."
        }
      ]
    }
  },
  {
    "id": "lesson_18_sets",
    "gate": "Gate E — Data Structures",
    "title": "Sets & Uniqueness Operations",
    "shortDescription": "Eliminate duplicate data automatically and perform mathematical set union, intersection, and difference.",
    "conceptExplanation": {
      "overview": "Sets are unordered collections containing only unique elements: `{1, 2, 3}`. When converting raw data into a set, all duplicate elements are automatically stripped away.",
      "keyPoints": [
        "Uniqueness guarantee: Elements can only appear once in a set.",
        "Fast membership test: Checking `x in my_set` runs in O(1) constant time.",
        "Set algebra: Supports mathematical Union (`A | B`), Intersection (`A & B`), and Difference (`A - B`).",
        "Unordered: Sets do not record insertion index, so items cannot be indexed with `[0]`."
      ],
      "whyItMatters": "Data pipelines frequently encounter duplicate user IDs, telemetry records, or tags. Sets guarantee clean unique entity tracking without writing manual deduplication loops.",
      "pythonCode": "raw_ids = [101, 102, 101, 103, 102]\nunique_ids = set(raw_ids)\nprint(f\"Unique: {unique_ids}, Count: {len(unique_ids)}\")"
    },
    "guidedSteps": [
      {
        "stepNumber": 1,
        "title": "Create Deduplicated Set",
        "instruction": "Add a Set node ('data.set') with initial elements '[101, 102, 101, 103, 102]'.",
        "conceptNote": "Set initialization automatically discards the repeated 101 and 102 values.",
        "nodeToInspect": "user_set",
        "pythonStatement": "unique_ids = set([101, 102, 101, 103, 102])"
      },
      {
        "stepNumber": 2,
        "title": "Inspect Set Cardinality",
        "instruction": "Check output port 'size', which evaluates to 3 unique elements.",
        "conceptNote": "len(unique_ids) returns the count of unique elements.",
        "nodeToInspect": "user_set",
        "pythonStatement": "print(len(unique_ids))"
      },
      {
        "stepNumber": 3,
        "title": "Check Membership",
        "instruction": "Set 'item' parameter to '101' and operation to 'contains' to verify membership output evaluates to True.",
        "conceptNote": "'in' keyword checks membership in O(1) average time.",
        "pythonStatement": "101 in unique_ids"
      }
    ],
    "starterGraph": {
      "name": "Set Deduplication Starter Graph",
      "nodes": [
        {
          "id": "set_node",
          "node_type": "data.set",
          "position": {
            "x": 120,
            "y": 150
          },
          "data": {
            "label": "UniqueIDs",
            "customData": {
              "operation": "create",
              "initial_set": "[101, 102, 101, 103, 102]"
            }
          }
        },
        {
          "id": "print_node",
          "node_type": "io.print",
          "position": {
            "x": 380,
            "y": 150
          },
          "data": {
            "label": "PrintSize"
          }
        }
      ],
      "edges": [
        {
          "id": "e1",
          "source": "set_node",
          "target": "print_node",
          "source_handle": "size",
          "target_handle": "value"
        }
      ]
    },
    "exercise": {
      "type": "debug_fix",
      "prompt": "A data pipeline expects to deduplicate incoming IDs '[10, 20, 10, 30]', but the Set node operation is currently misconfigured to 'intersection' against an empty set instead of 'create', producing size 0. Fix the Set node's operation to 'create' so output port 'size' evaluates to 3.",
      "brokenGraph": {
        "name": "Broken Set Deduplication Graph",
        "nodes": [
          {
            "id": "dedup_set",
            "node_type": "data.set",
            "position": {
              "x": 120,
              "y": 150
            },
            "data": {
              "label": "DedupSet",
              "customData": {
                "operation": "intersection",
                "initial_set": "[10, 20, 10, 30]"
              }
            }
          },
          {
            "id": "print_node",
            "node_type": "io.print",
            "position": {
              "x": 380,
              "y": 150
            },
            "data": {
              "label": "PrintSize"
            }
          }
        ],
        "edges": [
          {
            "id": "e1",
            "source": "dedup_set",
            "target": "print_node",
            "source_handle": "size",
            "target_handle": "value"
          }
        ]
      },
      "bugDescription": "The Set node operation is set to 'intersection' without a secondary set, producing an empty set of size 0.",
      "fixCriteria": {
        "expectedStatus": "success",
        "expectedTargetOutput": {
          "nodeId": "dedup_set",
          "portId": "size",
          "expectedValue": 3
        }
      },
      "hints": [
        "Select the 'dedup_set' node on the canvas.",
        "In the configuration drawer, change 'operation' from 'intersection' to 'create'.",
        "Run the flow to verify that [10, 20, 10, 30] deduplicates to {10, 20, 30} with size 3."
      ],
      "solutionExplanation": "Configuring the Set node operation to 'create' deduplicates [10, 20, 10, 30] into a unique set of 3 elements."
    }
  },
  {
    "id": "lesson_19_try_except",
    "gate": "Gate F — Modules & OOP",
    "title": "19. Exception Handling: Try, Except & Resilience",
    "shortDescription": "Safely catch expected errors like ZeroDivisionError and provide fallback recovery values.",
    "conceptExplanation": {
      "overview": "Runtime errors (exceptions) happen during program execution. Instead of letting errors crash the entire workflow, Python uses try...except...finally blocks to intercept specific errors and fall back to safe default values.",
      "keyPoints": [
        "The 'try' block runs protected code that might raise an exception.",
        "'except ZeroDivisionError' catches division by zero specifically without silencing unrelated errors.",
        "Fallback values provide graceful degradation so downstream nodes continue executing.",
        "The 'finally' block executes cleanup tasks regardless of whether an exception occurred."
      ],
      "whyItMatters": "Production pipelines handle unpredictable data like zero denominators, missing files, or bad API responses. Exception handling guarantees resilience and zero silent crashes.",
      "pythonCode": "try:\n    result = 100 / 0\nexcept ZeroDivisionError:\n    result = 0\nfinally:\n    print(\"Cleanup done\")"
    },
    "guidedSteps": [
      {
        "stepNumber": 1,
        "title": "Add a Divide Node",
        "instruction": "Add a Binary Op node ('core.binary_op') dividing 100 by 0 to generate a division-by-zero error.",
        "conceptNote": "In raw execution, 100 / 0 raises ZeroDivisionError and halts unshielded workflows.",
        "nodeToInspect": "calc_node",
        "pythonStatement": "100 / 0  # Raises ZeroDivisionError"
      },
      {
        "stepNumber": 2,
        "title": "Connect Try/Except Guard",
        "instruction": "Wire the divide result into the Try/Except node's 'try_val' port.",
        "conceptNote": "The Try/Except block catches the upstream ZeroDivisionError.",
        "nodeToInspect": "try_node",
        "pythonStatement": "try:\n    result = 100 / 0"
      },
      {
        "stepNumber": 3,
        "title": "Configure Fallback",
        "instruction": "Set the Try/Except node's fallback value to 0, catching 'ZeroDivisionError'.",
        "conceptNote": "The output port 'result' evaluates safely to 0 instead of failing the workflow.",
        "nodeToInspect": "try_node",
        "pythonStatement": "except ZeroDivisionError:\n    result = 0"
      }
    ],
    "starterGraph": {
      "name": "Exception Handling Starter Graph",
      "nodes": [
        {
          "id": "calc_node",
          "node_type": "core.binary_op",
          "position": {
            "x": 100,
            "y": 150
          },
          "data": {
            "label": "DivideByZero",
            "customData": {
              "a": 100,
              "b": 0,
              "operator": "/"
            }
          }
        },
        {
          "id": "try_node",
          "node_type": "control.try_except",
          "position": {
            "x": 380,
            "y": 150
          },
          "data": {
            "label": "TryGuard",
            "customData": {
              "exception_type": "ZeroDivisionError",
              "fallback": 0
            }
          }
        }
      ],
      "edges": [
        {
          "id": "e1",
          "source": "calc_node",
          "target": "try_node",
          "source_handle": "result",
          "target_handle": "try_val"
        }
      ]
    },
    "exercise": {
      "type": "build_graph",
      "prompt": "Construct a resilient calculation workflow. Place a Binary Operation node dividing 100 by 0, and protect it with a Try/Except node configured to catch 'ZeroDivisionError' with fallback 0. Verify output port 'result' recovers with value 0.",
      "targetRequirements": {
        "requiredNodeTypes": [
          "core.binary_op",
          "control.try_except"
        ],
        "requiredEdgeCount": 1,
        "expectedTargetOutput": {
          "portId": "result",
          "expectedValue": 0
        }
      },
      "hints": [
        "Add a Binary Op node with a=100, b=0, and operator='/'",
        "Connect its result output to a Try/Except node's 'try_val' port",
        "Set the Try/Except node fallback parameter to 0 and exception_type to 'ZeroDivisionError'"
      ],
      "solutionExplanation": "The Try/Except node intercepts the ZeroDivisionError from the division by zero and outputs the safe fallback value 0."
    }
  },
  {
    "id": "lesson_20_modules",
    "gate": "Gate F — Modules & OOP",
    "title": "20. Modules & Imports: Standard Libraries & JSON",
    "shortDescription": "Import approved Python standard library modules like json and parse structured data.",
    "conceptExplanation": {
      "overview": "Python's extensive Standard Library offers built-in modules for mathematical calculation (math), JSON serialization (json), and timestamps (datetime). In ALLI, modules are imported from a strict security allowlist.",
      "keyPoints": [
        "'import json' enables json.loads() to deserialize raw JSON strings into Python dictionaries.",
        "Security boundary: ALLI allows only approved standard modules (json, math, datetime, random) to prevent arbitrary system access.",
        "Parsed dictionary attributes become immediately accessible to downstream dataflow nodes."
      ],
      "whyItMatters": "Modern applications communicate almost entirely via JSON strings. Converting text into structured dictionaries is the baseline requirement of API and web development.",
      "pythonCode": "import json\n\npayload = '{\"name\": \"Alice\", \"score\": 95}'\ndata = json.loads(payload)\nprint(data[\"score\"])  # 95"
    },
    "guidedSteps": [
      {
        "stepNumber": 1,
        "title": "Add Module Import Node",
        "instruction": "Select 'lang.import' with module 'json' and action 'loads'.",
        "conceptNote": "Imports the standard json library and prepares json.loads() for execution.",
        "nodeToInspect": "json_import",
        "pythonStatement": "import json"
      },
      {
        "stepNumber": 2,
        "title": "Supply JSON String",
        "instruction": "Configure default input to '{\"name\": \"Alice\", \"score\": 95}'.",
        "conceptNote": "json.loads parses this string into a dictionary object.",
        "nodeToInspect": "json_import",
        "pythonStatement": "data = json.loads('{\"name\": \"Alice\", \"score\": 95}')"
      },
      {
        "stepNumber": 3,
        "title": "Extract Attribute",
        "instruction": "Wire result into a Dictionary node with operation 'get' and key 'score'.",
        "conceptNote": "Retrieves value 95 from the parsed dictionary.",
        "nodeToInspect": "dict_get",
        "pythonStatement": "score = data.get(\"score\")"
      }
    ],
    "starterGraph": {
      "name": "JSON Module Starter Graph",
      "nodes": [
        {
          "id": "json_node",
          "node_type": "lang.import",
          "position": {
            "x": 100,
            "y": 150
          },
          "data": {
            "label": "JSONLoads",
            "customData": {
              "module_name": "json",
              "function_name": "loads",
              "default_input": "{\"name\": \"Alice\", \"score\": 95}"
            }
          }
        },
        {
          "id": "dict_node",
          "node_type": "data.dict",
          "position": {
            "x": 380,
            "y": 150
          },
          "data": {
            "label": "GetScore",
            "customData": {
              "operation": "get",
              "key": "score"
            }
          }
        }
      ],
      "edges": [
        {
          "id": "e1",
          "source": "json_node",
          "target": "dict_node",
          "source_handle": "result",
          "target_handle": "dict_in"
        }
      ]
    },
    "exercise": {
      "type": "build_graph",
      "prompt": "Construct a workflow that parses a JSON string into structured data. Use a Module Import node ('lang.import') with module 'json' and function 'loads', and extract the 'score' attribute (value 95) using a Dictionary node.",
      "targetRequirements": {
        "requiredNodeTypes": [
          "lang.import",
          "data.dict"
        ],
        "requiredEdgeCount": 1,
        "expectedTargetOutput": {
          "portId": "val",
          "expectedValue": 95
        }
      },
      "hints": [
        "Add a Module Import node with module_name='json' and function_name='loads'",
        "Wire its result to a Dictionary node with operation='get' and key='score'"
      ],
      "solutionExplanation": "json.loads converts the JSON string into a Python dict, from which key 'score' returns 95."
    }
  },
  {
    "id": "lesson_21_classes",
    "gate": "Gate F — Modules & OOP",
    "title": "21. Classes & Instances: Object-Oriented Blueprints",
    "shortDescription": "Define class blueprints with constructor attributes and instantiate concrete objects.",
    "conceptExplanation": {
      "overview": "Object-Oriented Programming (OOP) bundles state (attributes) and behavior (methods) together into a single blueprint called a Class. Creating a concrete object from a class blueprint is called instantiation.",
      "keyPoints": [
        "'class Student:' defines the blueprint and type specification.",
        "'__init__' constructor initializes instance attributes (self.name, self.score) when an object is created.",
        "'Student(\"Alice\", 85)' instantiates a distinct object holding its own isolated state.",
        "In ALLI's DAG engine, instance objects are immutable value containers passed cleanly through typed ports."
      ],
      "whyItMatters": "As applications grow, modeling entities like Users, Orders, or Students as cohesive objects keeps data organized and prevents messy dispersed variables.",
      "pythonCode": "class Student:\n    def __init__(self, name, score=0):\n        self.name = name\n        self.score = score\n\ns1 = Student(\"Alice\", 85)\nprint(s1.name, s1.score)"
    },
    "guidedSteps": [
      {
        "stepNumber": 1,
        "title": "Define Student Class",
        "instruction": "Add an 'oop.class_def' node with class name 'Student' and attributes 'name, score'.",
        "conceptNote": "Declares the Student blueprint with constructor attributes.",
        "nodeToInspect": "student_class",
        "pythonStatement": "class Student:\n    def __init__(self, name, score):\n        self.name = name\n        self.score = score"
      },
      {
        "stepNumber": 2,
        "title": "Instantiate Object",
        "instruction": "Add an 'oop.instance' node connected to the class blueprint, passing name 'Alice' and score 85.",
        "conceptNote": "Creates a new Student object initialized with Alice and 85.",
        "nodeToInspect": "student_instance",
        "pythonStatement": "s1 = Student(\"Alice\", 85)"
      },
      {
        "stepNumber": 3,
        "title": "Inspect Instance",
        "instruction": "Run the workflow and check that output object contains { __class__: 'Student', name: 'Alice', score: 85 }.",
        "conceptNote": "The instance output port stores the student's attributes.",
        "nodeToInspect": "student_instance",
        "pythonStatement": "print(s1)"
      }
    ],
    "starterGraph": {
      "name": "Class and Instance Starter Graph",
      "nodes": [
        {
          "id": "class_def",
          "node_type": "oop.class_def",
          "position": {
            "x": 100,
            "y": 150
          },
          "data": {
            "label": "StudentClass",
            "customData": {
              "class_name": "Student",
              "attributes": "name, score"
            }
          }
        },
        {
          "id": "create_inst",
          "node_type": "oop.instance",
          "position": {
            "x": 380,
            "y": 150
          },
          "data": {
            "label": "AliceStudent",
            "customData": {
              "class_name": "Student",
              "arg_1_val": "Alice",
              "arg_2_val": 85
            }
          }
        }
      ],
      "edges": [
        {
          "id": "e1",
          "source": "class_def",
          "target": "create_inst",
          "source_handle": "class_ref",
          "target_handle": "class_in"
        }
      ]
    },
    "exercise": {
      "type": "build_graph",
      "prompt": "Create a Student object. Place a Class Definition node ('oop.class_def') with class_name 'Student' and attributes 'name, score'. Connect it to a Create Instance node ('oop.instance') with arg_1='Alice' and arg_2=85. Verify the instance is created with score 85.",
      "targetRequirements": {
        "requiredNodeTypes": [
          "oop.class_def",
          "oop.instance"
        ],
        "requiredEdgeCount": 1,
        "expectedTargetOutput": {
          "portId": "val",
          "expectedValue": {
            "__class__": "Student",
            "name": "Alice",
            "score": 85
          }
        }
      },
      "hints": [
        "Connect class_ref from oop.class_def to class_in on oop.instance",
        "Set arg_1 to 'Alice' and arg_2 to 85"
      ],
      "solutionExplanation": "The Class Definition establishes the Student blueprint, and Create Instance invokes __init__ to produce the student instance object."
    }
  },
  {
    "id": "lesson_22_methods",
    "gate": "Gate F — Modules & OOP",
    "title": "22. Methods & Object State: Invoking Behavior in a DAG",
    "shortDescription": "Call object methods, pass parameters, mutate object attributes, and return updated state.",
    "conceptExplanation": {
      "overview": "Methods are functions bound to an object that have access to its internal state via self. Calling a method can inspect attributes, perform calculations, and update the object's internal data.",
      "keyPoints": [
        "'def add_bonus(self, points):' updates 'self.score += points' and returns the new total.",
        "DAG consistency: In visual execution, calling a method produces an updated_instance to preserve predictable, acyclic state flow.",
        "Return values and modified instance states can be chained to downstream methods or output nodes."
      ],
      "whyItMatters": "Methods encapsulate business rules directly with the data they modify, ensuring changes happen through tested, controlled pathways.",
      "pythonCode": "class Student:\n    def __init__(self, name, score=85):\n        self.name = name\n        self.score = score\n    def add_bonus(self, points):\n        self.score += points\n        return self.score\n\ns = Student(\"Alice\", 85)\nnew_score = s.add_bonus(15)  # 100"
    },
    "guidedSteps": [
      {
        "stepNumber": 1,
        "title": "Instantiate Student",
        "instruction": "Start with a Student instance created with initial score 85.",
        "conceptNote": "Represents student Alice with score 85.",
        "nodeToInspect": "student_obj",
        "pythonStatement": "s = Student(\"Alice\", 85)"
      },
      {
        "stepNumber": 2,
        "title": "Call add_bonus Method",
        "instruction": "Add an 'oop.method_call' node with method_name 'add_bonus' and argument 15.",
        "conceptNote": "Passes 15 bonus points to the student's score attribute.",
        "nodeToInspect": "method_call",
        "pythonStatement": "new_score = s.add_bonus(15)"
      },
      {
        "stepNumber": 3,
        "title": "Inspect Updated Score",
        "instruction": "Run the flow and verify output 'result' returns 100 and 'updated_instance' reflects the modified score.",
        "conceptNote": "The returned score is 100 (85 + 15).",
        "nodeToInspect": "method_call",
        "pythonStatement": "print(new_score)  # 100"
      }
    ],
    "starterGraph": {
      "name": "Method Call Starter Graph",
      "nodes": [
        {
          "id": "inst_node",
          "node_type": "oop.instance",
          "position": {
            "x": 100,
            "y": 150
          },
          "data": {
            "label": "Alice85",
            "customData": {
              "class_name": "Student",
              "arg_1_val": "Alice",
              "arg_2_val": 85
            }
          }
        },
        {
          "id": "method_node",
          "node_type": "oop.method_call",
          "position": {
            "x": 380,
            "y": 150
          },
          "data": {
            "label": "AddBonus15",
            "customData": {
              "method_name": "add_bonus",
              "attribute_to_modify": "score",
              "operation": "increment",
              "default_arg": 15
            }
          }
        }
      ],
      "edges": [
        {
          "id": "e1",
          "source": "inst_node",
          "target": "method_node",
          "source_handle": "instance",
          "target_handle": "instance_in"
        }
      ]
    },
    "exercise": {
      "type": "build_graph",
      "prompt": "Update a student's score by invoking an object method. Create a Student instance with initial score 85, and connect it to a Method Call node ('oop.method_call') calling 'add_bonus' with argument 15. Verify that the returned score evaluates to 100.",
      "targetRequirements": {
        "requiredNodeTypes": [
          "oop.instance",
          "oop.method_call"
        ],
        "requiredEdgeCount": 1,
        "expectedTargetOutput": {
          "portId": "result",
          "expectedValue": 100
        }
      },
      "hints": [
        "Wire the instance output from oop.instance to instance_in on oop.method_call",
        "Set method_name to 'add_bonus' and arg to 15"
      ],
      "solutionExplanation": "Calling add_bonus(15) on the Student object increments its score from 85 to 100."
    }
  },
  {
    "id": "lesson_23_files",
    "gate": "Gate G — Real Programs",
    "title": "23. File I/O: Reading & Writing Files",
    "shortDescription": "Learn how programs persist data to disk and read files using Python context managers.",
    "conceptExplanation": {
      "overview": "Real programs must read data from persistent storage (like config files, logs, or datasets) and save results back to disk. In Python, file operations use the 'with open(...) as f:' pattern, which ensures the file is automatically closed even if errors occur.",
      "keyPoints": [
        "Use 'with open(path, mode)' to open files safely without resource leaks.",
        "Mode 'r' reads file contents, 'w' overwrites or creates a file, and 'a' appends.",
        "Always specify encoding='utf-8' for reliable cross-platform text processing."
      ],
      "whyItMatters": "Without file I/O, all calculations and state disappear as soon as the program finishes executing.",
      "pythonCode": "# Writing and Reading Files in Python\nwith open(\"output.txt\", \"w\", encoding=\"utf-8\") as f:\n    f.write(\"Status: Complete\\nScore: 100\\n\")\n\nwith open(\"output.txt\", \"r\", encoding=\"utf-8\") as f:\n    content = f.read()\nprint(content)"
    },
    "guidedSteps": [
      {
        "stepNumber": 1,
        "title": "Inspect the File Node",
        "instruction": "Add a File I/O node ('sys.file') to the canvas configured to read 'data.txt'.",
        "conceptNote": "File I/O nodes wrap Python's open() stream context manager.",
        "pythonStatement": "with open(\"data.txt\", \"r\", encoding=\"utf-8\") as _f:\n    data = _f.read()"
      },
      {
        "stepNumber": 2,
        "title": "Configure Mode & Content",
        "instruction": "In the Configuration Drawer, set mode to 'write' and content to 'ALLI Pipeline Output'.",
        "conceptNote": "Writing commits text directly to disk or virtual environment storage.",
        "pythonStatement": "_f.write(\"ALLI Pipeline Output\")"
      },
      {
        "stepNumber": 3,
        "title": "Execute and Verify Output",
        "instruction": "Run the workflow and inspect the 'result' and 'status' output ports.",
        "conceptNote": "The output port returns confirmation and written byte counts.",
        "pythonStatement": "print(f\"Bytes written: {len(data)}\")"
      }
    ],
    "starterGraph": {
      "name": "File I/O Starter Graph",
      "nodes": [
        {
          "id": "file_node",
          "node_type": "sys.file",
          "position": {
            "x": 160,
            "y": 150
          },
          "data": {
            "label": "WriteDataFile",
            "customData": {
              "file_path": "report.txt",
              "mode": "write",
              "content": "ALLI Pipeline Output"
            }
          }
        }
      ],
      "edges": []
    },
    "exercise": {
      "type": "build_graph",
      "prompt": "Configure a File I/O node ('sys.file') to write 'ALLI Pipeline Output' to 'report.txt'. Verify that the node executes successfully and returns written status.",
      "targetRequirements": {
        "requiredNodeTypes": [
          "sys.file"
        ],
        "expectedTargetOutput": {
          "portId": "status",
          "expectedValue": "success"
        }
      },
      "hints": [
        "Add a File I/O node from the palette or node menu",
        "Set file_path to 'report.txt' and mode to 'write'",
        "Set content to 'ALLI Pipeline Output'"
      ],
      "solutionExplanation": "The sys.file node executes a Python context manager write statement, returning status 'success'."
    }
  },
  {
    "id": "lesson_24_apis",
    "gate": "Gate G — Real Programs",
    "title": "24. Web APIs: Consuming REST Endpoints",
    "shortDescription": "Learn how programs fetch live external data and interact with REST APIs over HTTP.",
    "conceptExplanation": {
      "overview": "Modern applications rarely live in isolation—they consume external data from weather services, payment gateways, and databases over the web using HTTP. In Python, the 'requests' library provides simple methods (GET, POST) to fetch resources and parse JSON payloads.",
      "keyPoints": [
        "HTTP GET requests retrieve resources from a URL without modifying server state.",
        "HTTP POST requests send a JSON payload to create or process data on the server.",
        "Status code 200 means success; 404 means not found; 500 means server error.",
        "Use response.json() to convert raw HTTP responses into Python dictionaries and lists."
      ],
      "whyItMatters": "Web APIs connect your logic to real-time financial, scientific, and enterprise data around the globe.",
      "pythonCode": "import requests\n\n# Fetching student records from a REST API\nresponse = requests.get(\"https://api.example.com/students\", timeout=5)\nif response.status_code == 200:\n    students = response.json()\n    print(f\"Fetched {len(students)} records\")"
    },
    "guidedSteps": [
      {
        "stepNumber": 1,
        "title": "Add an HTTP Request Node",
        "instruction": "Add an HTTP Request node ('api.http_request') to the canvas.",
        "conceptNote": "The node initiates outbound network requests using Python's requests library.",
        "pythonStatement": "response = requests.get(\"https://api.example.com/students\")"
      },
      {
        "stepNumber": 2,
        "title": "Configure URL & Method",
        "instruction": "Set method to 'GET' and endpoint URL to 'https://api.example.com/students'.",
        "conceptNote": "GET requests retrieve structured data records.",
        "pythonStatement": "data = response.json()"
      },
      {
        "stepNumber": 3,
        "title": "Inspect Status & Payload",
        "instruction": "Run the workflow and observe the 'status_code' (200) and 'is_success' (true) ports.",
        "conceptNote": "Successful HTTP requests return status codes in the 200-299 range.",
        "pythonStatement": "assert response.status_code == 200"
      }
    ],
    "starterGraph": {
      "name": "HTTP Request Starter Graph",
      "nodes": [
        {
          "id": "http_node",
          "node_type": "api.http_request",
          "position": {
            "x": 160,
            "y": 150
          },
          "data": {
            "label": "FetchStudentsAPI",
            "customData": {
              "url": "https://api.example.com/students",
              "method": "GET",
              "timeout": 5
            }
          }
        }
      ],
      "edges": []
    },
    "exercise": {
      "type": "build_graph",
      "prompt": "Configure an HTTP Request node ('api.http_request') to send a GET request to 'https://api.example.com/students'. Verify that status_code evaluates to 200 and is_success evaluates to true.",
      "targetRequirements": {
        "requiredNodeTypes": [
          "api.http_request"
        ],
        "expectedTargetOutput": {
          "portId": "status_code",
          "expectedValue": 200
        }
      },
      "hints": [
        "Place an HTTP Request node on the canvas",
        "Set method to 'GET' and URL to 'https://api.example.com/students'",
        "Run the flow and check status_code output"
      ],
      "solutionExplanation": "The HTTP Request node queries the endpoint and receives a 200 OK status code with parsed JSON records."
    }
  },
  {
    "id": "lesson_25_databases",
    "gate": "Gate G — Real Programs",
    "title": "25. Databases: Querying & Filtering Records",
    "shortDescription": "Learn how programs filter, search, and aggregate structured records from in-memory datasets.",
    "conceptExplanation": {
      "overview": "In modern pipelines, programs query structured collections of records using filter predicates (e.g., status == 'active') to find specific items, compute counts, and project required fields. In ALLI, db.query serves as an in-memory collection query connector (filtering lists of record dictionaries) simulating table queries without needing external SQL/NoSQL database servers.",
      "keyPoints": [
        "In-Memory Collection Query: Filters structured record dictionaries using key-value predicate matching.",
        "Predicate Matching: Checks attributes like 'status', 'score', or 'role' on each record dictionary.",
        "Query Operations: Supports 'find' (returns matching list), 'count' (number of matches), and 'first' (first matching record)."
      ],
      "whyItMatters": "Structured query filtering allows workflows to cleanly transform and inspect tabular data before saving or printing.",
      "pythonCode": "# In-Memory Dataset Querying in Python\nrecords = [\n    {\"id\": 1, \"name\": \"Alice\", \"score\": 95, \"status\": \"active\"},\n    {\"id\": 2, \"name\": \"Bob\", \"score\": 82, \"status\": \"active\"},\n    {\"id\": 3, \"name\": \"Charlie\", \"score\": 70, \"status\": \"inactive\"},\n]\nactive_students = [r for r in records if r[\"status\"] == \"active\"]\nprint(f\"Active count: {len(active_students)}\")"
    },
    "guidedSteps": [
      {
        "stepNumber": 1,
        "title": "Add a Database Query Node",
        "instruction": "Add a Database Query node ('db.query') to the canvas.",
        "conceptNote": "Connects to an in-memory structured dataset (list of record dicts) with zero external server dependencies.",
        "pythonStatement": "matched = [r for r in dataset if r.get(\"status\") == \"active\"]"
      },
      {
        "stepNumber": 2,
        "title": "Configure Filter Parameters",
        "instruction": "Set table_name to 'students', filter_key to 'status', and filter_value to 'active'.",
        "conceptNote": "Filters records matching key == 'status' and value == 'active'.",
        "pythonStatement": "# Filtering for status == \"active\""
      },
      {
        "stepNumber": 3,
        "title": "Inspect Filter Count",
        "instruction": "Run the workflow and inspect the 'count' output port (expected: 2).",
        "conceptNote": "Two out of the three student records have status 'active'.",
        "pythonStatement": "count = len(matched)  # 2"
      }
    ],
    "starterGraph": {
      "name": "Database Query Starter Graph",
      "nodes": [
        {
          "id": "db_node",
          "node_type": "db.query",
          "position": {
            "x": 160,
            "y": 150
          },
          "data": {
            "label": "FilterActiveStudents",
            "customData": {
              "table_name": "students",
              "filter_key": "status",
              "filter_value": "active",
              "operation": "find"
            }
          }
        }
      ],
      "edges": []
    },
    "exercise": {
      "type": "build_graph",
      "prompt": "Query the students collection to filter for active records where filter_key is 'status' and filter_value is 'active'. Verify that the 'count' output returns 2.",
      "targetRequirements": {
        "requiredNodeTypes": [
          "db.query"
        ],
        "expectedTargetOutput": {
          "portId": "count",
          "expectedValue": 2
        }
      },
      "hints": [
        "Place a Database Query node on the canvas",
        "Set filter_key to 'status' and filter_value to 'active'",
        "Run the flow and verify count equals 2"
      ],
      "solutionExplanation": "The db.query node filters the student records for status='active', matching Alice and Bob (count: 2)."
    }
  },
  {
    "id": "lesson_26_capstone",
    "gate": "Gate G — Real Programs",
    "title": "26. Capstone Pipeline: Building a Real Application",
    "shortDescription": "Combine data ingestion, error resilience, database querying, and output formatting into an end-to-end program.",
    "conceptExplanation": {
      "overview": "Congratulations on reaching the Level 2 Capstone! A real software system connects all 8 fundamental programming pillars: it ingests data from a file or API, shields execution with Try/Except error handling, queries and transforms records with functions and collections, and formats clean output logs.",
      "keyPoints": [
        "Pillars 1-3: Input data and perform calculations.",
        "Pillars 4-5: Make control flow decisions and reuse logic through functions.",
        "Pillars 6-7: Organize collections into lists/dicts and encapsulate state with classes.",
        "Pillar 8: Ingest real-world data, guard against exceptions, and persist results."
      ],
      "whyItMatters": "Mastering the full pipeline transforms you from someone who merely connects visual blocks into an engineer who understands full-stack program architecture.",
      "pythonCode": "try:\n    # 1. Ingest Data\n    with open(\"report.txt\", \"w\", encoding=\"utf-8\") as f:\n        f.write(\"Pipeline Started\")\n    \n    # 2. Query Active Records\n    records = [\n        {\"id\": 1, \"name\": \"Alice\", \"score\": 95, \"status\": \"active\"},\n        {\"id\": 2, \"name\": \"Bob\", \"score\": 82, \"status\": \"active\"}\n    ]\n    active = [r for r in records if r[\"status\"] == \"active\"]\n    \n    # 3. Output Result\n    print(f\"Processed {len(active)} active records successfully.\")\nexcept Exception as err:\n    print(f\"Pipeline error: {err}\")"
    },
    "guidedSteps": [
      {
        "stepNumber": 1,
        "title": "Ingest Data via File I/O",
        "instruction": "Add a File I/O node ('sys.file') writing 'Pipeline Started' to 'report.txt'.",
        "conceptNote": "Establishes persistent state on the filesystem.",
        "pythonStatement": "with open(\"report.txt\", \"w\") as f: f.write(\"Pipeline Started\")"
      },
      {
        "stepNumber": 2,
        "title": "Filter Records with Database Query",
        "instruction": "Add a Database Query node ('db.query') filtering for status == 'active'.",
        "conceptNote": "Applies data transformation and filtering to structured records.",
        "pythonStatement": "active = [r for r in records if r[\"status\"] == \"active\"]"
      },
      {
        "stepNumber": 3,
        "title": "Connect to Print Output",
        "instruction": "Connect the query 'count' port to a Print node to log the final pipeline summary.",
        "conceptNote": "Final output reflects the processed dataset count.",
        "pythonStatement": "print(f\"Active count: {count}\")"
      }
    ],
    "starterGraph": {
      "name": "Capstone Pipeline Starter Graph",
      "nodes": [
        {
          "id": "file_step",
          "node_type": "sys.file",
          "position": {
            "x": 100,
            "y": 150
          },
          "data": {
            "label": "InitializeFile",
            "customData": {
              "file_path": "report.txt",
              "mode": "write",
              "content": "Pipeline Started"
            }
          }
        },
        {
          "id": "db_step",
          "node_type": "db.query",
          "position": {
            "x": 360,
            "y": 150
          },
          "data": {
            "label": "FilterActive",
            "customData": {
              "table_name": "students",
              "filter_key": "status",
              "filter_value": "active",
              "operation": "find"
            }
          }
        },
        {
          "id": "print_step",
          "node_type": "io.print",
          "position": {
            "x": 620,
            "y": 150
          },
          "data": {
            "label": "LogProcessedCount",
            "customData": {
              "prefix": "Processed active records: "
            }
          }
        }
      ],
      "edges": [
        {
          "id": "e1",
          "source": "file_step",
          "target": "db_step",
          "source_handle": "out",
          "target_handle": "in"
        },
        {
          "id": "e2",
          "source": "db_step",
          "target": "print_step",
          "source_handle": "count",
          "target_handle": "value"
        }
      ]
    },
    "exercise": {
      "type": "build_graph",
      "prompt": "Construct an end-to-end Capstone Pipeline: Use a File I/O node ('sys.file') to initialize state, pipe into a Database Query node ('db.query') filtering for 'active' records, and connect the query 'count' to a Print node ('io.print'). Verify that the printed result equals 2.",
      "targetRequirements": {
        "requiredNodeTypes": [
          "sys.file",
          "db.query",
          "io.print"
        ],
        "requiredEdgeCount": 2,
        "expectedTargetOutput": {
          "portId": "result",
          "expectedValue": 2
        }
      },
      "hints": [
        "Include sys.file, db.query, and io.print on the canvas",
        "Wire file out to db in, and db count to print value",
        "Run the flow and verify print output equals 2"
      ],
      "solutionExplanation": "The full pipeline initializes the file, queries active database records, and logs the count (2) via Print."
    }
  },
  {
    "id": "lesson_27_third_party_packages",
    "gate": "Gate H — The Extensible Ecosystem",
    "title": "27. Third-Party Packages: Discovery & Dependencies",
    "shortDescription": "Explore Python's package ecosystem. Search the package registry, inspect dependencies, and declare pinned package versions for reproducible workflows.",
    "conceptExplanation": {
      "overview": "Python's superpower is its vast open-source package ecosystem hosted on PyPI. Real-world workflows rely on third-party libraries (such as requests, pandas, numpy) to extend core Python capabilities. In ALLI, the Package Registry (/packages) discovers and catalogs available packages with standardized metadata, while dependency pinning in requirements.txt ensures workflows execute identically across development, testing, and production environments.",
      "keyPoints": [
        "Package Registry (/packages): Discovers standard library and external PyPI packages with version, category, and node count metadata.",
        "Dependency Pinning: Using exact version constraints (e.g., requests==2.31.0) prevents breaking changes from unexpected upstream updates.",
        "Manifest Generation: Workflows automatically synthesize requirements.txt manifests pairing declared dependencies with containerized Dockerfiles.",
        "Security Safeguards: Package names and versions are treated as untrusted inputs and validated against strict naming patterns."
      ],
      "whyItMatters": "Unpinned dependencies cause production builds to break when upstream libraries release incompatible changes. Strict version manifests ensure complete execution reproducibility.",
      "pythonCode": "# requirements.txt\n# requests==2.31.0\n\nimport requests\n\nresponse = requests.get(\"https://api.example.com/students\", timeout=5)\nprint(f\"Status: {response.status_code}\")"
    },
    "guidedSteps": [
      {
        "stepNumber": 1,
        "title": "Discover Packages in Registry",
        "instruction": "Query the ALLI Package Registry (/packages) to inspect available libraries, their classification (stdlib vs. external), version tags, and install commands.",
        "conceptNote": "The registry provides unified metadata contracts including name, version, summary, and categories for standard and external libraries.",
        "pythonStatement": "import importlib.metadata; installed = [d.metadata[\"Name\"] for d in importlib.metadata.distributions()]"
      },
      {
        "stepNumber": 2,
        "title": "Declare Pinned Dependencies",
        "instruction": "Attach external dependencies (such as requests==2.31.0) to your workflow blueprint to specify the exact versions needed for runtime execution.",
        "conceptNote": "Pinning dependencies guarantees that Docker builds and standalone Python runs use the exact tested library versions.",
        "pythonStatement": "import requests  # Pinned dependency: requests==2.31.0"
      },
      {
        "stepNumber": 3,
        "title": "Synthesize Manifest & Verify Parity",
        "instruction": "Generate the standalone Python script and requirements.txt manifest, confirming that external packages are cleanly pinned and standard libraries are excluded.",
        "conceptNote": "Standard libraries (like math, json, datetime) are excluded from requirements.txt, while external packages are pinned with exact version specifications.",
        "pythonStatement": "with open(\"requirements.txt\", \"w\") as f: f.write(\"requests==2.31.0\\n\")"
      }
    ],
    "starterGraph": {
      "name": "Third-Party Packages Starter",
      "dependencies": [
        "requests==2.31.0"
      ],
      "nodes": [
        {
          "id": "pkg_step",
          "node_type": "api.http_request",
          "position": {
            "x": 100,
            "y": 150
          },
          "data": {
            "method": "GET",
            "url": "https://api.example.com/students",
            "customData": {
              "method": "GET",
              "url": "https://api.example.com/students",
              "package": "requests",
              "version": "2.31.0"
            }
          }
        },
        {
          "id": "print_step",
          "node_type": "io.print",
          "position": {
            "x": 450,
            "y": 150
          },
          "data": {
            "label": "Log Status"
          }
        }
      ],
      "edges": [
        {
          "id": "e1",
          "source": "pkg_step",
          "target": "print_step",
          "source_handle": "status_code",
          "target_handle": "value"
        }
      ]
    },
    "exercise": {
      "type": "build_graph",
      "prompt": "Construct a workflow utilizing third-party package dependencies: Place an HTTP Request node ('api.http_request') configured with method 'GET' and URL 'https://api.example.com/students', pipe its 'status_code' to an Output Print node ('io.print'), and declare 'requests==2.31.0' in the workflow dependencies. Verify that status_code equals 200 and requirements.txt pins requests==2.31.0.",
      "targetRequirements": {
        "requiredNodeTypes": [
          "api.http_request",
          "io.print"
        ],
        "requiredEdgeCount": 1,
        "expectedTargetOutput": {
          "portId": "status_code",
          "expectedValue": 200
        }
      },
      "hints": [
        "Include api.http_request and io.print on the canvas",
        "Wire status_code from http_request to value of print",
        "Verify that requirements.txt contains requests==2.31.0"
      ],
      "solutionExplanation": "The workflow queries the API using the pinned requests library (2.31.0) and prints status 200, generating a reproducible requirements.txt manifest."
    }
  },
  {
    "id": "lesson_28_ast_introspection",
    "gate": "Gate H — The Extensible Ecosystem",
    "title": "28. Dynamic AST Introspection & Code Analysis",
    "shortDescription": "Learn how Python converts source text into an Abstract Syntax Tree (ast.parse) to inspect functions, imports, and variables without executing arbitrary code.",
    "conceptExplanation": {
      "overview": "Before Python code executes, the interpreter compiles source text into an Abstract Syntax Tree (AST)—a structural hierarchy representing expressions, statements, functions, and control flow. Using Python's built-in ast module (ast.parse, ast.walk, ast.NodeVisitor), developer tools inspect, lint, and validate code safely without executing it. In ALLI, AST inspection connects the visual graph to generated Python, confirming that visual nodes map 1:1 to generated AST symbols while detecting syntax errors and unapproved calls.",
      "keyPoints": [
        "AST Parsing (ast.parse): Converts Python source text into a structured syntax tree without runtime execution.",
        "Visitor Pattern (ast.NodeVisitor): Traverses syntax nodes to identify functions (FunctionDef), classes (ClassDef), imports (Import), and calls (Call).",
        "Static Pre-Flight Validation: Detects syntax errors, unbalanced brackets, and dangerous functions (eval, exec) before execution starts.",
        "Graph-to-AST Parity: Compares visual nodes against AST call nodes, ensuring visual logic matches generated code 1:1."
      ],
      "whyItMatters": "Executing untrusted code directly is dangerous. AST inspection enables deterministic static analysis, powering linters, autocompletion, dynamic node generators, and code verification safely.",
      "pythonCode": "import ast\n\ncode = \"\"\"\nimport math\n\ndef calculate_circle_area(radius):\n    return math.pi * (radius ** 2)\n\"\"\"\n\ntree = ast.parse(code)\nfunctions = [n.name for n in ast.walk(tree) if isinstance(n, ast.FunctionDef)]\nprint(f\"Parsed functions: {functions}\")"
    },
    "guidedSteps": [
      {
        "stepNumber": 1,
        "title": "Parse Source Code into AST",
        "instruction": "Use Python's ast.parse() to transform a Python source string into an Abstract Syntax Tree and verify syntax integrity.",
        "conceptNote": "ast.parse() raises SyntaxError with exact line and column diagnostics if the input code is malformed.",
        "pythonStatement": "tree = ast.parse('import math\\nx = math.sqrt(49)')"
      },
      {
        "stepNumber": 2,
        "title": "Traverse Nodes with ast.NodeVisitor",
        "instruction": "Subclass ast.NodeVisitor to inspect function definitions, imported modules, and callable expressions across the tree.",
        "conceptNote": "Visitor methods (visit_FunctionDef, visit_Call) are invoked automatically for each matching syntax element.",
        "pythonStatement": "funcs = [n.name for n in ast.walk(tree) if isinstance(n, ast.FunctionDef)]"
      },
      {
        "stepNumber": 3,
        "title": "Verify Graph-to-AST Parity",
        "instruction": "Cross-reference visual graph nodes against synthesized AST calls to confirm deterministic 1:1 parity and detect dropped logic.",
        "conceptNote": "Comparing visual nodes with AST symbols guarantees that no visual nodes are dropped or corrupted during code synthesis.",
        "pythonStatement": "assert len(funcs) > 0, 'AST must contain synthesized pipeline functions'"
      }
    ],
    "starterGraph": {
      "name": "AST Introspection Starter Graph",
      "nodes": [
        {
          "id": "func_def",
          "node_type": "func.definition",
          "position": {
            "x": 100,
            "y": 150
          },
          "data": {
            "label": "ComputeArea",
            "customData": {
              "function_name": "compute_area",
              "parameters": "radius",
              "return_expr": "3.14159 * (radius ** 2)"
            }
          }
        },
        {
          "id": "func_call",
          "node_type": "func.call",
          "position": {
            "x": 450,
            "y": 150
          },
          "data": {
            "label": "CallArea",
            "customData": {
              "function_name": "compute_area",
              "arguments": "7"
            }
          }
        }
      ],
      "edges": [
        {
          "id": "e1",
          "source": "func_def",
          "target": "func_call",
          "source_handle": "out",
          "target_handle": "in"
        }
      ]
    },
    "exercise": {
      "type": "build_graph",
      "prompt": "Construct a workflow and verify AST introspection: Place a Function Definition node ('func.definition') named 'compute_area', connect it to a Function Call node ('func.call'), and verify that the synthesized Python code produces valid AST syntax with both FunctionDef and Call symbols.",
      "targetRequirements": {
        "requiredNodeTypes": [
          "func.definition",
          "func.call"
        ],
        "requiredEdgeCount": 1,
        "expectedTargetOutput": {
          "portId": "result",
          "expectedValue": 153.93791,
          "tolerance": 0.01
        }
      },
      "hints": [
        "Add func.definition and func.call to the canvas",
        "Connect the function definition to the caller",
        "Verify that the AST inspection detects function compute_area and call compute_area"
      ],
      "solutionExplanation": "The visual graph synthesizes a Python function definition and call, successfully verified via AST inspection with zero syntax errors."
    }
  }
]