diff --git a/curriculum/challenges/_meta/learn-lambda-functions-by-building-an-expense-tracker/meta.json b/curriculum/challenges/_meta/learn-lambda-functions-by-building-an-expense-tracker/meta.json index 76198ec7c20..91febd38cd1 100644 --- a/curriculum/challenges/_meta/learn-lambda-functions-by-building-an-expense-tracker/meta.json +++ b/curriculum/challenges/_meta/learn-lambda-functions-by-building-an-expense-tracker/meta.json @@ -63,127 +63,127 @@ "title": "Step 13" }, { - "id": "658238f7604f154ea9a23e1e", + "id": "66314f2add0a8b57da5d6d91", "title": "Step 14" }, { - "id": "65823b0167fd894f4a7ea60a", + "id": "658238f7604f154ea9a23e1e", "title": "Step 15" }, { - "id": "65823bbbdb4eaa4f9d20a0fb", + "id": "65823b0167fd894f4a7ea60a", "title": "Step 16" }, { - "id": "65823cfc74aa564ffc460489", + "id": "65823bbbdb4eaa4f9d20a0fb", "title": "Step 17" }, { - "id": "65823dde36392f505a39f7c7", + "id": "65823cfc74aa564ffc460489", "title": "Step 18" }, { - "id": "65823e87c9741750a22085a7", + "id": "65823dde36392f505a39f7c7", "title": "Step 19" }, { - "id": "65823ff0d4b991510fade1a8", + "id": "65823e87c9741750a22085a7", "title": "Step 20" }, { - "id": "65824111a09164518320088d", + "id": "65823ff0d4b991510fade1a8", "title": "Step 21" }, { - "id": "658244fdf4b0265334711664", + "id": "65824111a09164518320088d", "title": "Step 22" }, { - "id": "65824561f3478e5371a33ae5", + "id": "658244fdf4b0265334711664", "title": "Step 23" }, { - "id": "658246c28575d653d1f89b59", + "id": "65824561f3478e5371a33ae5", "title": "Step 24" }, { - "id": "65824872894f59546e3084e2", + "id": "658246c28575d653d1f89b59", "title": "Step 25" }, { - "id": "65824a1b16631c54fa524154", + "id": "65824872894f59546e3084e2", "title": "Step 26" }, { - "id": "65824c7b4e2da85597693dcf", + "id": "65824a1b16631c54fa524154", "title": "Step 27" }, { - "id": "65824dfdb6815d563b2d3256", + "id": "65824c7b4e2da85597693dcf", "title": "Step 28" }, { - "id": "6582507654b3ed5712341382", + "id": "65824dfdb6815d563b2d3256", "title": "Step 29" }, { - "id": "658252f6b1526d57b103d48a", + "id": "6582507654b3ed5712341382", "title": "Step 30" }, { - "id": "658254db6e12485a48130f57", + "id": "658252f6b1526d57b103d48a", "title": "Step 31" }, { - "id": "658255d5f955175b270f251d", + "id": "658254db6e12485a48130f57", "title": "Step 32" }, { - "id": "6582575b8089f85b8b92d7c8", + "id": "658255d5f955175b270f251d", "title": "Step 33" }, { - "id": "658258c0e5fbe85c14c060cf", + "id": "6582575b8089f85b8b92d7c8", "title": "Step 34" }, { - "id": "65825a9520a0795c8afbef50", + "id": "658258c0e5fbe85c14c060cf", "title": "Step 35" }, { - "id": "65825b758fe85a5cebabc8c5", + "id": "65825a9520a0795c8afbef50", "title": "Step 36" }, { - "id": "65825cda2668995d5168e37c", + "id": "65825b758fe85a5cebabc8c5", "title": "Step 37" }, { - "id": "65825e96b5db5f5dee6bf57c", + "id": "65825cda2668995d5168e37c", "title": "Step 38" }, { - "id": "6582601b2987045e8e7da994", + "id": "65825e96b5db5f5dee6bf57c", "title": "Step 39" }, { - "id": "6582622cb6c11a5f4c5d79b4", + "id": "6582601b2987045e8e7da994", "title": "Step 40" }, { - "id": "6582687859366a618424d84b", + "id": "6582622cb6c11a5f4c5d79b4", "title": "Step 41" }, { - "id": "65826a6e9d189a623141c726", + "id": "6582687859366a618424d84b", "title": "Step 42" }, { - "id": "65826af5b226a5628aa154b1", + "id": "65826a6e9d189a623141c726", "title": "Step 43" }, { - "id": "65826befd75db5632bd73df6", + "id": "65826af5b226a5628aa154b1", "title": "Step 44" } ], diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md index d62f58870c1..78a72e6c1b9 100644 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md @@ -2,7 +2,7 @@ id: 658238f7604f154ea9a23e1e title: الخطوة 14 challengeType: 20 -dashedName: step-14 +dashedName: step-15 --- # --description-- diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md index 5eae727a6cb..64b6a73d3c3 100644 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md @@ -2,7 +2,7 @@ id: 65823b0167fd894f4a7ea60a title: الخطوة 15 challengeType: 20 -dashedName: step-15 +dashedName: step-16 --- # --description-- diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md index c9de5f0fb91..51b16c5a9fe 100644 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md @@ -2,7 +2,7 @@ id: 65823bbbdb4eaa4f9d20a0fb title: الخطوة 16 challengeType: 20 -dashedName: step-16 +dashedName: step-17 --- # --description-- diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md index e91e6ec03bf..668346817e2 100644 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md @@ -2,7 +2,7 @@ id: 65823cfc74aa564ffc460489 title: الخطوة 17 challengeType: 20 -dashedName: step-17 +dashedName: step-18 --- # --description-- diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md index 3ae500d89b2..a3b4f19a260 100644 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md @@ -2,7 +2,7 @@ id: 65823dde36392f505a39f7c7 title: الخطوة 18 challengeType: 20 -dashedName: step-18 +dashedName: step-19 --- # --description-- diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md index bdc1ffd128f..1ffb0108caa 100644 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md @@ -2,7 +2,7 @@ id: 65823e87c9741750a22085a7 title: الخطوة 19 challengeType: 20 -dashedName: step-19 +dashedName: step-20 --- # --description-- diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md index b1dc2eadedb..dee332629f9 100644 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md @@ -2,7 +2,7 @@ id: 65823ff0d4b991510fade1a8 title: الخطوة 20 challengeType: 20 -dashedName: step-20 +dashedName: step-21 --- # --description-- diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md index d0402bd080d..acdf5739f36 100644 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md @@ -2,7 +2,7 @@ id: 65824111a09164518320088d title: الخطوة 21 challengeType: 20 -dashedName: step-21 +dashedName: step-22 --- # --description-- diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md index 2a245fcb678..d87b53fc194 100644 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md @@ -2,7 +2,7 @@ id: 658244fdf4b0265334711664 title: الخطوة 22 challengeType: 20 -dashedName: step-22 +dashedName: step-23 --- # --description-- diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md index 6206587c61a..6173f220ff5 100644 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md @@ -2,7 +2,7 @@ id: 65824561f3478e5371a33ae5 title: الخطوة 23 challengeType: 20 -dashedName: step-23 +dashedName: step-24 --- # --description-- diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md index fd4eb09a765..5365efab11e 100644 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md @@ -2,7 +2,7 @@ id: 658246c28575d653d1f89b59 title: الخطوة 24 challengeType: 20 -dashedName: step-24 +dashedName: step-25 --- # --description-- diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md index 3063be12946..c3fbd93028a 100644 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md @@ -2,7 +2,7 @@ id: 65824872894f59546e3084e2 title: الخطوة 25 challengeType: 20 -dashedName: step-25 +dashedName: step-26 --- # --description-- diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md index f5755ec145f..a066acf12fc 100644 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md @@ -2,7 +2,7 @@ id: 65824a1b16631c54fa524154 title: الخطوة 26 challengeType: 20 -dashedName: step-26 +dashedName: step-27 --- # --description-- diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md index a3b2b63db30..e9becb9a2af 100644 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md @@ -2,7 +2,7 @@ id: 65824c7b4e2da85597693dcf title: الخطوة 27 challengeType: 20 -dashedName: step-27 +dashedName: step-28 --- # --description-- diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md index 5c4d86143c6..ce6b596d73b 100644 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md @@ -2,7 +2,7 @@ id: 65824dfdb6815d563b2d3256 title: الخطوة 28 challengeType: 20 -dashedName: step-28 +dashedName: step-29 --- # --description-- diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md index 2d01bb17ff3..8fb74cb73de 100644 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md @@ -2,7 +2,7 @@ id: 6582507654b3ed5712341382 title: الخطوة 29 challengeType: 20 -dashedName: step-29 +dashedName: step-30 --- # --description-- diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md index feab4cdb500..dabaf1edfe4 100644 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md @@ -2,7 +2,7 @@ id: 658252f6b1526d57b103d48a title: الخطوة 30 challengeType: 20 -dashedName: step-30 +dashedName: step-31 --- # --description-- diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md index c6ac76cac79..788bc745c47 100644 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md @@ -2,7 +2,7 @@ id: 658254db6e12485a48130f57 title: الخطوة 31 challengeType: 20 -dashedName: step-31 +dashedName: step-32 --- # --description-- diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md index f2815484ca4..a855e60dc75 100644 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md @@ -2,7 +2,7 @@ id: 658255d5f955175b270f251d title: الخطوة 32 challengeType: 20 -dashedName: step-32 +dashedName: step-33 --- # --description-- diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md index 1c44bf25164..a431060e224 100644 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md @@ -2,7 +2,7 @@ id: 6582575b8089f85b8b92d7c8 title: الخطوة 33 challengeType: 20 -dashedName: step-33 +dashedName: step-34 --- # --description-- diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md index f64885b8a82..5042ffa6bc1 100644 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md @@ -2,7 +2,7 @@ id: 658258c0e5fbe85c14c060cf title: الخطوة 34 challengeType: 20 -dashedName: step-34 +dashedName: step-35 --- # --description-- diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md index b217c14f7fa..91de67ae8fd 100644 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md @@ -2,7 +2,7 @@ id: 65825a9520a0795c8afbef50 title: الخطوة 35 challengeType: 20 -dashedName: step-35 +dashedName: step-36 --- # --description-- diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md index 49fa901315f..c58ee0d8bb9 100644 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md @@ -2,7 +2,7 @@ id: 65825b758fe85a5cebabc8c5 title: الخطوة 36 challengeType: 20 -dashedName: step-36 +dashedName: step-37 --- # --description-- diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md index 9b954b3343e..929a9ff03cc 100644 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md @@ -2,7 +2,7 @@ id: 65825cda2668995d5168e37c title: الخطوة 37 challengeType: 20 -dashedName: step-37 +dashedName: step-38 --- # --description-- diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md index 4df5f8bc494..ae85c9f3a43 100644 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md @@ -2,7 +2,7 @@ id: 65825e96b5db5f5dee6bf57c title: الخطوة 38 challengeType: 20 -dashedName: step-38 +dashedName: step-39 --- # --description-- diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md index 683aa673eb1..7707278e10a 100644 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md @@ -2,7 +2,7 @@ id: 6582601b2987045e8e7da994 title: الخطوة 39 challengeType: 20 -dashedName: step-39 +dashedName: step-40 --- # --description-- diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md index c41d29eadcd..d0210c1333b 100644 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md @@ -2,7 +2,7 @@ id: 6582622cb6c11a5f4c5d79b4 title: الخطوة 40 challengeType: 20 -dashedName: step-40 +dashedName: step-41 --- # --description-- diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md index dd8e1bdd00d..e7a5db3fde5 100644 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md @@ -2,7 +2,7 @@ id: 6582687859366a618424d84b title: الخطوة 41 challengeType: 20 -dashedName: step-41 +dashedName: step-42 --- # --description-- diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md index c9ce912308e..9e6f1de548d 100644 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md @@ -2,7 +2,7 @@ id: 65826a6e9d189a623141c726 title: الخطوة 42 challengeType: 20 -dashedName: step-42 +dashedName: step-43 --- # --description-- diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md index daf39ddc082..e75ac1eaf64 100644 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md @@ -2,7 +2,7 @@ id: 65826af5b226a5628aa154b1 title: الخطوة 43 challengeType: 20 -dashedName: step-43 +dashedName: step-44 --- # --description-- diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826befd75db5632bd73df6.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826befd75db5632bd73df6.md deleted file mode 100644 index 730115052e1..00000000000 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826befd75db5632bd73df6.md +++ /dev/null @@ -1,145 +0,0 @@ ---- -id: 65826befd75db5632bd73df6 -title: الخطوة 44 -challengeType: 20 -dashedName: step-44 ---- - -# --description-- - -You can use the `__name__` variable to determine if a Python script is being run as the main program or if it is being imported as a module (code written in another Python file). - -If the value of `__name__` is set to `'__main__'`, it implies that the current script is the main program, and not a module. - -As a final step, create an `if` statement to check if `__name__ == '__main__'`, and move the `main()` call inside this block. - -With that, the expense tracker project is complete! - -# --hints-- - -You should have `if __name__ == '__main__':` in your code. - -```js -assert.match(code,/^if\s+__name__\s*==\s*("|')__main__\1\s*:/m); -``` - -Your `main()` call should be inside the `if` statement. - -```js -assert.match(code, /^if\s+__name__\s*==\s*("|')__main__\1\s*:\s*main\s*\(\s*\)/m); -``` - -# --seed-- - -## --seed-contents-- - -```py -def add_expense(expenses, amount, category): - expenses.append({'amount': amount, 'category': category}) - -def print_expenses(expenses): - for expense in expenses: - print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - -def total_expenses(expenses): - return sum(map(lambda expense: expense['amount'], expenses)) - -def filter_expenses_by_category(expenses, category): - return filter(lambda expense: expense['category'] == category, expenses) - - -def main(): - expenses = [] - while True: - print('\nExpense Tracker') - print('1. Add an expense') - print('2. List all expenses') - print('3. Show total expenses') - print('4. Filter expenses by category') - print('5. Exit') - - choice = input('Enter your choice: ') - - if choice == '1': - amount = float(input('Enter amount: ')) - category = input('Enter category: ') - add_expense(expenses, amount, category) - - elif choice == '2': - print('\nAll Expenses:') - print_expenses(expenses) - - elif choice == '3': - print('\nTotal Expenses: ', total_expenses(expenses)) - - elif choice == '4': - category = input('Enter category to filter: ') - print(f'\nExpenses for {category}:') - expenses_from_category = filter_expenses_by_category(expenses, category) - print_expenses(expenses_from_category) - - elif choice == '5': - print('Exiting the program.') - break - ---fcc-editable-region-- -main() ---fcc-editable-region-- -``` - - -# --solutions-- - -```py -def add_expense(expenses, amount, category): - expenses.append({'amount': amount, 'category': category}) - -def print_expenses(expenses): - for expense in expenses: - print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - -def total_expenses(expenses): - return sum(map(lambda expense: expense['amount'], expenses)) - -def filter_expenses_by_category(expenses, category): - return filter(lambda expense: expense['category'] == category, expenses) - - -def main(): - expenses = [] - while True: - print('\nExpense Tracker') - print('1. Add an expense') - print('2. List all expenses') - print('3. Show total expenses') - print('4. Filter expenses by category') - print('5. Exit') - - choice = input('Enter your choice: ') - - if choice == '1': - amount = float(input('Enter amount: ')) - category = input('Enter category: ') - add_expense(expenses, amount, category) - - elif choice == '2': - print('\nAll Expenses:') - print_expenses(expenses) - - elif choice == '3': - print('\nTotal Expenses: ', total_expenses(expenses)) - - elif choice == '4': - category = input('Enter category to filter: ') - print(f'\nExpenses for {category}:') - expenses_from_category = filter_expenses_by_category(expenses, category) - print_expenses(expenses_from_category) - - elif choice == '5': - print('Exiting the program.') - break - -if __name__ == '__main__': - main() - -``` diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/66314f2add0a8b57da5d6d91.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/66314f2add0a8b57da5d6d91.md new file mode 100644 index 00000000000..43669da4b07 --- /dev/null +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/66314f2add0a8b57da5d6d91.md @@ -0,0 +1,43 @@ +--- +id: 66314f2add0a8b57da5d6d91 +title: Step 14 +challengeType: 20 +dashedName: step-14 +--- + +# --description-- + +You should see something like `` printed on the console, which is the string representation of the map object returned by `map()`. + +To obtain a readable output you need to turn the map object into a list. Do it by passing the `map()` call as the argument to the `list()` function. + +# --hints-- + +You should pass the `map()` call as the argument to the `list()` function. + +```js +({ test: () => assert(runPython(`_Node(_code).has_call("print(list(map(test, [2,3,5,8])))")`)) }) +``` + +# --seed-- + +## --seed-contents-- + +```py +def add_expense(expenses, amount, category): + expenses.append({'amount': amount, 'category': category}) + +def print_expenses(expenses): + for expense in expenses: + print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') + +def total_expenses(expenses): + pass + +--fcc-editable-region-- +test = lambda x: x * 2 +print(map(test, [2, 3, 5, 8])) +--fcc-editable-region-- + +expenses = [] +``` diff --git a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md index 12d5d940f89..886988d9c70 100644 --- a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md +++ b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md @@ -2,7 +2,7 @@ id: 658238f7604f154ea9a23e1e title: 第 14 步 challengeType: 20 -dashedName: step-14 +dashedName: step-15 --- # --description-- diff --git a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md index 9b902d3c4d7..a8bdbae2159 100644 --- a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md +++ b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md @@ -2,7 +2,7 @@ id: 65823b0167fd894f4a7ea60a title: 步驟15 challengeType: 20 -dashedName: step-15 +dashedName: step-16 --- # --description-- diff --git a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md index 772a39c40ca..873644e9308 100644 --- a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md +++ b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md @@ -2,7 +2,7 @@ id: 65823bbbdb4eaa4f9d20a0fb title: 步驟 16 challengeType: 20 -dashedName: step-16 +dashedName: step-17 --- # --description-- diff --git a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md index 656ff52fc46..d17f8f6571d 100644 --- a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md +++ b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md @@ -2,7 +2,7 @@ id: 65823cfc74aa564ffc460489 title: Step 17 challengeType: 20 -dashedName: step-17 +dashedName: step-18 --- # --description-- diff --git a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md index a68b9a8846a..96fa62cfc4b 100644 --- a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md +++ b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md @@ -2,7 +2,7 @@ id: 65823dde36392f505a39f7c7 title: 步驟 18 challengeType: 20 -dashedName: step-18 +dashedName: step-19 --- # --description-- diff --git a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md index 782a592683a..87427352991 100644 --- a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md +++ b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md @@ -2,7 +2,7 @@ id: 65823e87c9741750a22085a7 title: 步驟 19 challengeType: 20 -dashedName: step-19 +dashedName: step-20 --- # --description-- diff --git a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md index 2da741a5e09..b766495504a 100644 --- a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md +++ b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md @@ -2,7 +2,7 @@ id: 65823ff0d4b991510fade1a8 title: 步驟 20 challengeType: 20 -dashedName: step-20 +dashedName: step-21 --- # --description-- diff --git a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md index 93f7c647c37..9e222343dcf 100644 --- a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md +++ b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md @@ -2,7 +2,7 @@ id: 65824111a09164518320088d title: 步驟21 challengeType: 20 -dashedName: step-21 +dashedName: step-22 --- # --description-- diff --git a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md index 0422d85e8ef..3df881bb274 100644 --- a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md +++ b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md @@ -2,7 +2,7 @@ id: 658244fdf4b0265334711664 title: 步驟 22 challengeType: 20 -dashedName: step-22 +dashedName: step-23 --- # --description-- diff --git a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md index 226d50044da..924e037e3e8 100644 --- a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md +++ b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md @@ -2,7 +2,7 @@ id: 65824561f3478e5371a33ae5 title: 步驟-23 challengeType: 20 -dashedName: step-23 +dashedName: step-24 --- # --description-- diff --git a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md index af9b2587e39..964d261430d 100644 --- a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md +++ b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md @@ -2,7 +2,7 @@ id: 658246c28575d653d1f89b59 title: 步驟 24 challengeType: 20 -dashedName: step-24 +dashedName: step-25 --- # --description-- diff --git a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md index d91c0d622f3..b7c9d61c724 100644 --- a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md +++ b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md @@ -2,7 +2,7 @@ id: 65824872894f59546e3084e2 title: 步驟 25 challengeType: 20 -dashedName: step-25 +dashedName: step-26 --- # --description-- diff --git a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md index 3b933dadaee..7f6a8e0d5cc 100644 --- a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md +++ b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md @@ -2,7 +2,7 @@ id: 65824a1b16631c54fa524154 title: 步驟 26 challengeType: 20 -dashedName: step-26 +dashedName: step-27 --- # --description-- diff --git a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md index 15881486448..070c4436d48 100644 --- a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md +++ b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md @@ -2,7 +2,7 @@ id: 65824c7b4e2da85597693dcf title: 步驟 27 challengeType: 20 -dashedName: step-27 +dashedName: step-28 --- # --description-- diff --git a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md index b217338b920..39073ba36e8 100644 --- a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md +++ b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md @@ -2,7 +2,7 @@ id: 65824dfdb6815d563b2d3256 title: 第 28 步 challengeType: 20 -dashedName: step-28 +dashedName: step-29 --- # --description-- diff --git a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md index 1a7335b39a0..2d379924259 100644 --- a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md +++ b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md @@ -2,7 +2,7 @@ id: 6582507654b3ed5712341382 title: 步驟 29 challengeType: 20 -dashedName: step-29 +dashedName: step-30 --- # --description-- diff --git a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md index 7d0977e488b..150c207bf94 100644 --- a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md +++ b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md @@ -2,7 +2,7 @@ id: 658252f6b1526d57b103d48a title: 第 30 步 challengeType: 20 -dashedName: step-30 +dashedName: step-31 --- # --description-- diff --git a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md index bee506ad5f5..5a1dd9bf72f 100644 --- a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md +++ b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md @@ -2,7 +2,7 @@ id: 658254db6e12485a48130f57 title: 步驟 31 challengeType: 20 -dashedName: step-31 +dashedName: step-32 --- # --description-- diff --git a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md index 77efcaf8d52..ea6c1c705fe 100644 --- a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md +++ b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md @@ -2,7 +2,7 @@ id: 658255d5f955175b270f251d title: 步驟 32 challengeType: 20 -dashedName: step-32 +dashedName: step-33 --- # --description-- diff --git a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md index e402a5448e8..e24e24f626d 100644 --- a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md +++ b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md @@ -2,7 +2,7 @@ id: 6582575b8089f85b8b92d7c8 title: 步驟 33 challengeType: 20 -dashedName: step-33 +dashedName: step-34 --- # --description-- diff --git a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md index c1d42d6c071..02d05e97463 100644 --- a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md +++ b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md @@ -2,7 +2,7 @@ id: 658258c0e5fbe85c14c060cf title: 步驟 34 challengeType: 20 -dashedName: step-34 +dashedName: step-35 --- # --description-- diff --git a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md index 1159edfd592..7d61ca18208 100644 --- a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md +++ b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md @@ -2,7 +2,7 @@ id: 65825a9520a0795c8afbef50 title: 步驟 35 challengeType: 20 -dashedName: step-35 +dashedName: step-36 --- # --description-- diff --git a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md index 946e683dcd4..f0a4a78e443 100644 --- a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md +++ b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md @@ -2,7 +2,7 @@ id: 65825b758fe85a5cebabc8c5 title: 步驟 36 challengeType: 20 -dashedName: step-36 +dashedName: step-37 --- # --description-- diff --git a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md index 1297c3c28f4..4f27c510ec6 100644 --- a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md +++ b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md @@ -2,7 +2,7 @@ id: 65825cda2668995d5168e37c title: 步驟 37 challengeType: 20 -dashedName: step-37 +dashedName: step-38 --- # --description-- diff --git a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md index 2524a456612..d190a82f278 100644 --- a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md +++ b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md @@ -2,7 +2,7 @@ id: 65825e96b5db5f5dee6bf57c title: 步驟 38 challengeType: 20 -dashedName: step-38 +dashedName: step-39 --- # --description-- diff --git a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md index 2fde77bd0b6..6bef05673a8 100644 --- a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md +++ b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md @@ -2,7 +2,7 @@ id: 6582601b2987045e8e7da994 title: 步驟 39 challengeType: 20 -dashedName: step-39 +dashedName: step-40 --- # --description-- diff --git a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md index 86c7ff3a3bc..99e383ad03c 100644 --- a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md +++ b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md @@ -2,7 +2,7 @@ id: 6582622cb6c11a5f4c5d79b4 title: 步驟 40 challengeType: 20 -dashedName: step-40 +dashedName: step-41 --- # --description-- diff --git a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md index ce0e58e43e3..725990d0810 100644 --- a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md +++ b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md @@ -2,7 +2,7 @@ id: 6582687859366a618424d84b title: 步驟 41 challengeType: 20 -dashedName: step-41 +dashedName: step-42 --- # --description-- diff --git a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md index ab86d86ec5f..263ed016ac2 100644 --- a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md +++ b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md @@ -2,7 +2,7 @@ id: 65826a6e9d189a623141c726 title: 步驟 42 challengeType: 20 -dashedName: step-42 +dashedName: step-43 --- # --description-- diff --git a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md index 1d5bbf35d38..d251584867d 100644 --- a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md +++ b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md @@ -2,7 +2,7 @@ id: 65826af5b226a5628aa154b1 title: 第 43 步 challengeType: 20 -dashedName: step-43 +dashedName: step-44 --- # --description-- diff --git a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826befd75db5632bd73df6.md b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826befd75db5632bd73df6.md deleted file mode 100644 index 3706cca20d3..00000000000 --- a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826befd75db5632bd73df6.md +++ /dev/null @@ -1,145 +0,0 @@ ---- -id: 65826befd75db5632bd73df6 -title: 步驟 44 -challengeType: 20 -dashedName: step-44 ---- - -# --description-- - -You can use the `__name__` variable to determine if a Python script is being run as the main program or if it is being imported as a module (code written in another Python file). - -If the value of `__name__` is set to `'__main__'`, it implies that the current script is the main program, and not a module. - -As a final step, create an `if` statement to check if `__name__ == '__main__'`, and move the `main()` call inside this block. - -With that, the expense tracker project is complete! - -# --hints-- - -You should have `if __name__ == '__main__':` in your code. - -```js -assert.match(code,/^if\s+__name__\s*==\s*("|')__main__\1\s*:/m); -``` - -Your `main()` call should be inside the `if` statement. - -```js -assert.match(code, /^if\s+__name__\s*==\s*("|')__main__\1\s*:\s*main\s*\(\s*\)/m); -``` - -# --seed-- - -## --seed-contents-- - -```py -def add_expense(expenses, amount, category): - expenses.append({'amount': amount, 'category': category}) - -def print_expenses(expenses): - for expense in expenses: - print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - -def total_expenses(expenses): - return sum(map(lambda expense: expense['amount'], expenses)) - -def filter_expenses_by_category(expenses, category): - return filter(lambda expense: expense['category'] == category, expenses) - - -def main(): - expenses = [] - while True: - print('\nExpense Tracker') - print('1. Add an expense') - print('2. List all expenses') - print('3. Show total expenses') - print('4. Filter expenses by category') - print('5. Exit') - - choice = input('Enter your choice: ') - - if choice == '1': - amount = float(input('Enter amount: ')) - category = input('Enter category: ') - add_expense(expenses, amount, category) - - elif choice == '2': - print('\nAll Expenses:') - print_expenses(expenses) - - elif choice == '3': - print('\nTotal Expenses: ', total_expenses(expenses)) - - elif choice == '4': - category = input('Enter category to filter: ') - print(f'\nExpenses for {category}:') - expenses_from_category = filter_expenses_by_category(expenses, category) - print_expenses(expenses_from_category) - - elif choice == '5': - print('Exiting the program.') - break - ---fcc-editable-region-- -main() ---fcc-editable-region-- -``` - - -# --solutions-- - -```py -def add_expense(expenses, amount, category): - expenses.append({'amount': amount, 'category': category}) - -def print_expenses(expenses): - for expense in expenses: - print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - -def total_expenses(expenses): - return sum(map(lambda expense: expense['amount'], expenses)) - -def filter_expenses_by_category(expenses, category): - return filter(lambda expense: expense['category'] == category, expenses) - - -def main(): - expenses = [] - while True: - print('\nExpense Tracker') - print('1. Add an expense') - print('2. List all expenses') - print('3. Show total expenses') - print('4. Filter expenses by category') - print('5. Exit') - - choice = input('Enter your choice: ') - - if choice == '1': - amount = float(input('Enter amount: ')) - category = input('Enter category: ') - add_expense(expenses, amount, category) - - elif choice == '2': - print('\nAll Expenses:') - print_expenses(expenses) - - elif choice == '3': - print('\nTotal Expenses: ', total_expenses(expenses)) - - elif choice == '4': - category = input('Enter category to filter: ') - print(f'\nExpenses for {category}:') - expenses_from_category = filter_expenses_by_category(expenses, category) - print_expenses(expenses_from_category) - - elif choice == '5': - print('Exiting the program.') - break - -if __name__ == '__main__': - main() - -``` diff --git a/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/66314f2add0a8b57da5d6d91.md b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/66314f2add0a8b57da5d6d91.md new file mode 100644 index 00000000000..43669da4b07 --- /dev/null +++ b/curriculum/challenges/chinese-traditional/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/66314f2add0a8b57da5d6d91.md @@ -0,0 +1,43 @@ +--- +id: 66314f2add0a8b57da5d6d91 +title: Step 14 +challengeType: 20 +dashedName: step-14 +--- + +# --description-- + +You should see something like `` printed on the console, which is the string representation of the map object returned by `map()`. + +To obtain a readable output you need to turn the map object into a list. Do it by passing the `map()` call as the argument to the `list()` function. + +# --hints-- + +You should pass the `map()` call as the argument to the `list()` function. + +```js +({ test: () => assert(runPython(`_Node(_code).has_call("print(list(map(test, [2,3,5,8])))")`)) }) +``` + +# --seed-- + +## --seed-contents-- + +```py +def add_expense(expenses, amount, category): + expenses.append({'amount': amount, 'category': category}) + +def print_expenses(expenses): + for expense in expenses: + print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') + +def total_expenses(expenses): + pass + +--fcc-editable-region-- +test = lambda x: x * 2 +print(map(test, [2, 3, 5, 8])) +--fcc-editable-region-- + +expenses = [] +``` diff --git a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md index 12d5d940f89..886988d9c70 100644 --- a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md +++ b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md @@ -2,7 +2,7 @@ id: 658238f7604f154ea9a23e1e title: 第 14 步 challengeType: 20 -dashedName: step-14 +dashedName: step-15 --- # --description-- diff --git a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md index 325ebe5f1fc..c4b3c2b737a 100644 --- a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md +++ b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md @@ -2,7 +2,7 @@ id: 65823b0167fd894f4a7ea60a title: 步骤15 challengeType: 20 -dashedName: step-15 +dashedName: step-16 --- # --description-- diff --git a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md index 50e8c839e6e..e5a24107a7b 100644 --- a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md +++ b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md @@ -2,7 +2,7 @@ id: 65823bbbdb4eaa4f9d20a0fb title: 步骤 16 challengeType: 20 -dashedName: step-16 +dashedName: step-17 --- # --description-- diff --git a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md index 656ff52fc46..d17f8f6571d 100644 --- a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md +++ b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md @@ -2,7 +2,7 @@ id: 65823cfc74aa564ffc460489 title: Step 17 challengeType: 20 -dashedName: step-17 +dashedName: step-18 --- # --description-- diff --git a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md index 1ef22b2d002..04756066800 100644 --- a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md +++ b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md @@ -2,7 +2,7 @@ id: 65823dde36392f505a39f7c7 title: 步骤 18 challengeType: 20 -dashedName: step-18 +dashedName: step-19 --- # --description-- diff --git a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md index 8c0d3f34be7..40dbcb91e73 100644 --- a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md +++ b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md @@ -2,7 +2,7 @@ id: 65823e87c9741750a22085a7 title: 步骤 19 challengeType: 20 -dashedName: step-19 +dashedName: step-20 --- # --description-- diff --git a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md index c0f7009dbab..ecb22b82fb1 100644 --- a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md +++ b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md @@ -2,7 +2,7 @@ id: 65823ff0d4b991510fade1a8 title: 步骤 20 challengeType: 20 -dashedName: step-20 +dashedName: step-21 --- # --description-- diff --git a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md index 753ff32fb0c..27fd7fbaa55 100644 --- a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md +++ b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md @@ -2,7 +2,7 @@ id: 65824111a09164518320088d title: 步骤21 challengeType: 20 -dashedName: step-21 +dashedName: step-22 --- # --description-- diff --git a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md index 41a07e1f9d9..584423b8316 100644 --- a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md +++ b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md @@ -2,7 +2,7 @@ id: 658244fdf4b0265334711664 title: 步骤 22 challengeType: 20 -dashedName: step-22 +dashedName: step-23 --- # --description-- diff --git a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md index 23fc07b63fd..9f4165077db 100644 --- a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md +++ b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md @@ -2,7 +2,7 @@ id: 65824561f3478e5371a33ae5 title: 步骤-23 challengeType: 20 -dashedName: step-23 +dashedName: step-24 --- # --description-- diff --git a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md index b940cef2078..ab0d5a447f5 100644 --- a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md +++ b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md @@ -2,7 +2,7 @@ id: 658246c28575d653d1f89b59 title: 步骤 24 challengeType: 20 -dashedName: step-24 +dashedName: step-25 --- # --description-- diff --git a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md index 68818220002..c454e5facd1 100644 --- a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md +++ b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md @@ -2,7 +2,7 @@ id: 65824872894f59546e3084e2 title: 步骤 25 challengeType: 20 -dashedName: step-25 +dashedName: step-26 --- # --description-- diff --git a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md index 20d2313e71d..05668d8a194 100644 --- a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md +++ b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md @@ -2,7 +2,7 @@ id: 65824a1b16631c54fa524154 title: 步骤 26 challengeType: 20 -dashedName: step-26 +dashedName: step-27 --- # --description-- diff --git a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md index f100b7f7da3..d69c03009ef 100644 --- a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md +++ b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md @@ -2,7 +2,7 @@ id: 65824c7b4e2da85597693dcf title: 步骤 27 challengeType: 20 -dashedName: step-27 +dashedName: step-28 --- # --description-- diff --git a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md index b217338b920..39073ba36e8 100644 --- a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md +++ b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md @@ -2,7 +2,7 @@ id: 65824dfdb6815d563b2d3256 title: 第 28 步 challengeType: 20 -dashedName: step-28 +dashedName: step-29 --- # --description-- diff --git a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md index 6eec61d8754..103a6809e9f 100644 --- a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md +++ b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md @@ -2,7 +2,7 @@ id: 6582507654b3ed5712341382 title: 步骤 29 challengeType: 20 -dashedName: step-29 +dashedName: step-30 --- # --description-- diff --git a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md index 7d0977e488b..150c207bf94 100644 --- a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md +++ b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md @@ -2,7 +2,7 @@ id: 658252f6b1526d57b103d48a title: 第 30 步 challengeType: 20 -dashedName: step-30 +dashedName: step-31 --- # --description-- diff --git a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md index 4e708398403..0ef76458cdc 100644 --- a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md +++ b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md @@ -2,7 +2,7 @@ id: 658254db6e12485a48130f57 title: 步骤 31 challengeType: 20 -dashedName: step-31 +dashedName: step-32 --- # --description-- diff --git a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md index d1e49a8056b..ef5c516100e 100644 --- a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md +++ b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md @@ -2,7 +2,7 @@ id: 658255d5f955175b270f251d title: 步骤 32 challengeType: 20 -dashedName: step-32 +dashedName: step-33 --- # --description-- diff --git a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md index 645cd7ba27c..018a38b9c81 100644 --- a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md +++ b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md @@ -2,7 +2,7 @@ id: 6582575b8089f85b8b92d7c8 title: 步骤 33 challengeType: 20 -dashedName: step-33 +dashedName: step-34 --- # --description-- diff --git a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md index 60f7c1a995e..8e9d1d5134f 100644 --- a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md +++ b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md @@ -2,7 +2,7 @@ id: 658258c0e5fbe85c14c060cf title: 步骤 34 challengeType: 20 -dashedName: step-34 +dashedName: step-35 --- # --description-- diff --git a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md index 360883a4397..fb0708b70e7 100644 --- a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md +++ b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md @@ -2,7 +2,7 @@ id: 65825a9520a0795c8afbef50 title: 步骤 35 challengeType: 20 -dashedName: step-35 +dashedName: step-36 --- # --description-- diff --git a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md index f068d18021c..ecac230ed7e 100644 --- a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md +++ b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md @@ -2,7 +2,7 @@ id: 65825b758fe85a5cebabc8c5 title: 步骤 36 challengeType: 20 -dashedName: step-36 +dashedName: step-37 --- # --description-- diff --git a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md index 81db34a8061..846307cbc99 100644 --- a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md +++ b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md @@ -2,7 +2,7 @@ id: 65825cda2668995d5168e37c title: 步骤 37 challengeType: 20 -dashedName: step-37 +dashedName: step-38 --- # --description-- diff --git a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md index a4f37c75047..e85ae393b60 100644 --- a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md +++ b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md @@ -2,7 +2,7 @@ id: 65825e96b5db5f5dee6bf57c title: 步骤 38 challengeType: 20 -dashedName: step-38 +dashedName: step-39 --- # --description-- diff --git a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md index f73d2135033..dd0543ac9e7 100644 --- a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md +++ b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md @@ -2,7 +2,7 @@ id: 6582601b2987045e8e7da994 title: 步骤 39 challengeType: 20 -dashedName: step-39 +dashedName: step-40 --- # --description-- diff --git a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md index 40d3d0e1f64..935e5fd579f 100644 --- a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md +++ b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md @@ -2,7 +2,7 @@ id: 6582622cb6c11a5f4c5d79b4 title: 步骤 40 challengeType: 20 -dashedName: step-40 +dashedName: step-41 --- # --description-- diff --git a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md index 9a60b1f99ad..b169b076af7 100644 --- a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md +++ b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md @@ -2,7 +2,7 @@ id: 6582687859366a618424d84b title: 步骤 41 challengeType: 20 -dashedName: step-41 +dashedName: step-42 --- # --description-- diff --git a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md index 41b9348d754..927fb97835a 100644 --- a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md +++ b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md @@ -2,7 +2,7 @@ id: 65826a6e9d189a623141c726 title: 步骤 42 challengeType: 20 -dashedName: step-42 +dashedName: step-43 --- # --description-- diff --git a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md index 1d5bbf35d38..d251584867d 100644 --- a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md +++ b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md @@ -2,7 +2,7 @@ id: 65826af5b226a5628aa154b1 title: 第 43 步 challengeType: 20 -dashedName: step-43 +dashedName: step-44 --- # --description-- diff --git a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826befd75db5632bd73df6.md b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826befd75db5632bd73df6.md deleted file mode 100644 index ecf9c1ce267..00000000000 --- a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826befd75db5632bd73df6.md +++ /dev/null @@ -1,145 +0,0 @@ ---- -id: 65826befd75db5632bd73df6 -title: 步骤 44 -challengeType: 20 -dashedName: step-44 ---- - -# --description-- - -You can use the `__name__` variable to determine if a Python script is being run as the main program or if it is being imported as a module (code written in another Python file). - -If the value of `__name__` is set to `'__main__'`, it implies that the current script is the main program, and not a module. - -As a final step, create an `if` statement to check if `__name__ == '__main__'`, and move the `main()` call inside this block. - -With that, the expense tracker project is complete! - -# --hints-- - -You should have `if __name__ == '__main__':` in your code. - -```js -assert.match(code,/^if\s+__name__\s*==\s*("|')__main__\1\s*:/m); -``` - -Your `main()` call should be inside the `if` statement. - -```js -assert.match(code, /^if\s+__name__\s*==\s*("|')__main__\1\s*:\s*main\s*\(\s*\)/m); -``` - -# --seed-- - -## --seed-contents-- - -```py -def add_expense(expenses, amount, category): - expenses.append({'amount': amount, 'category': category}) - -def print_expenses(expenses): - for expense in expenses: - print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - -def total_expenses(expenses): - return sum(map(lambda expense: expense['amount'], expenses)) - -def filter_expenses_by_category(expenses, category): - return filter(lambda expense: expense['category'] == category, expenses) - - -def main(): - expenses = [] - while True: - print('\nExpense Tracker') - print('1. Add an expense') - print('2. List all expenses') - print('3. Show total expenses') - print('4. Filter expenses by category') - print('5. Exit') - - choice = input('Enter your choice: ') - - if choice == '1': - amount = float(input('Enter amount: ')) - category = input('Enter category: ') - add_expense(expenses, amount, category) - - elif choice == '2': - print('\nAll Expenses:') - print_expenses(expenses) - - elif choice == '3': - print('\nTotal Expenses: ', total_expenses(expenses)) - - elif choice == '4': - category = input('Enter category to filter: ') - print(f'\nExpenses for {category}:') - expenses_from_category = filter_expenses_by_category(expenses, category) - print_expenses(expenses_from_category) - - elif choice == '5': - print('Exiting the program.') - break - ---fcc-editable-region-- -main() ---fcc-editable-region-- -``` - - -# --solutions-- - -```py -def add_expense(expenses, amount, category): - expenses.append({'amount': amount, 'category': category}) - -def print_expenses(expenses): - for expense in expenses: - print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - -def total_expenses(expenses): - return sum(map(lambda expense: expense['amount'], expenses)) - -def filter_expenses_by_category(expenses, category): - return filter(lambda expense: expense['category'] == category, expenses) - - -def main(): - expenses = [] - while True: - print('\nExpense Tracker') - print('1. Add an expense') - print('2. List all expenses') - print('3. Show total expenses') - print('4. Filter expenses by category') - print('5. Exit') - - choice = input('Enter your choice: ') - - if choice == '1': - amount = float(input('Enter amount: ')) - category = input('Enter category: ') - add_expense(expenses, amount, category) - - elif choice == '2': - print('\nAll Expenses:') - print_expenses(expenses) - - elif choice == '3': - print('\nTotal Expenses: ', total_expenses(expenses)) - - elif choice == '4': - category = input('Enter category to filter: ') - print(f'\nExpenses for {category}:') - expenses_from_category = filter_expenses_by_category(expenses, category) - print_expenses(expenses_from_category) - - elif choice == '5': - print('Exiting the program.') - break - -if __name__ == '__main__': - main() - -``` diff --git a/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/66314f2add0a8b57da5d6d91.md b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/66314f2add0a8b57da5d6d91.md new file mode 100644 index 00000000000..43669da4b07 --- /dev/null +++ b/curriculum/challenges/chinese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/66314f2add0a8b57da5d6d91.md @@ -0,0 +1,43 @@ +--- +id: 66314f2add0a8b57da5d6d91 +title: Step 14 +challengeType: 20 +dashedName: step-14 +--- + +# --description-- + +You should see something like `` printed on the console, which is the string representation of the map object returned by `map()`. + +To obtain a readable output you need to turn the map object into a list. Do it by passing the `map()` call as the argument to the `list()` function. + +# --hints-- + +You should pass the `map()` call as the argument to the `list()` function. + +```js +({ test: () => assert(runPython(`_Node(_code).has_call("print(list(map(test, [2,3,5,8])))")`)) }) +``` + +# --seed-- + +## --seed-contents-- + +```py +def add_expense(expenses, amount, category): + expenses.append({'amount': amount, 'category': category}) + +def print_expenses(expenses): + for expense in expenses: + print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') + +def total_expenses(expenses): + pass + +--fcc-editable-region-- +test = lambda x: x * 2 +print(map(test, [2, 3, 5, 8])) +--fcc-editable-region-- + +expenses = [] +``` diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658212ba98182f3e855e85f9.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658212ba98182f3e855e85f9.md index 90725056be2..51f05e69ed6 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658212ba98182f3e855e85f9.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658212ba98182f3e855e85f9.md @@ -13,7 +13,7 @@ Start by defining a function named `add_expense` that takes three parameters: `e # --hints-- -You should declare a function named `add_expense`. +You should use the `def` keyword to declare a function named `add_expense`. ```js ({ test: () => assert(runPython(` diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65821c1c40ccac44adf38e6b.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65821c1c40ccac44adf38e6b.md index c35f36685dd..f2392be1fac 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65821c1c40ccac44adf38e6b.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65821c1c40ccac44adf38e6b.md @@ -7,13 +7,13 @@ dashedName: step-2 # --description-- -A list in Python is a built-in data type that allows you to store many items in a single data structure. In Python, you create a list by putting items inside square brackets `[]`, with each item separated from the following one by a comma. +A list in Python is a built-in data type that allows you to store many items in a single data structure. In Python, you create a list by putting items inside square brackets (`[]`), with each item separated from the following one by a comma. ```py numbers = [1, 2, 3, 4] ``` -Create an empty list named `expenses`. You will use it to store each of your expenses. +Use a pair of square brackets to create an empty list named `expenses`. You will use it to store each of your expenses. # --hints-- diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65821fcc010c3245718f2a06.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65821fcc010c3245718f2a06.md index 0c83f09ee12..7f5af99e0a8 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65821fcc010c3245718f2a06.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65821fcc010c3245718f2a06.md @@ -7,21 +7,29 @@ dashedName: step-3 # --description-- -The `expenses` parameter of your `add_expense` function will be a list of expenses. You want to be able to add items at the end of your list. For that you can use the `.append()` list method: +The `expenses` parameter of your `add_expense` function will be a list of expenses. You want to be able to add items at the end of your list. For that you'll use the `.append()` list method: ```py my_list = [2, 4, 7] my_list.append(3) ``` -In the example above, after appending `3`, `my_list` would be `[2, 4, 7, 3]`. Replace `pass` with a call to the `.append()` method on the `expenses` list. Don't pass any arguments to `.append()` for now. +In the example above, after appending `3`, `my_list` would be `[2, 4, 7, 3]`. + +Replace `pass` with a call to the `.append()` method on the `expenses` list. Don't pass any arguments to `.append()` for now. # --hints-- You should have `expenses.append()` in your function. ```js -assert.match(code, /^\s+expenses\.append\s*\(\s*\)/m) +({ test: () => assert(runPython(`_Node(_code).find_function("add_expense").has_stmt("expenses.append()")`)) }) +``` + +You should not have `pass` in your function. + +```js +({ test: () => assert.isFalse(runPython(`_Node(_code).find_function("add_expense").has_pass()`)) }) ``` # --seed-- diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822308ded1ba4632f66aa3.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822308ded1ba4632f66aa3.md index 5c850342519..e89afc026b6 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822308ded1ba4632f66aa3.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822308ded1ba4632f66aa3.md @@ -7,7 +7,7 @@ dashedName: step-4 # --description-- -A dictionary is another built-in data type in Python. A dictionary is a collection of data in the form of *key*-*value* pairs. Dictionaries are defined with curly braces `{}` and they contain key-value pairs separated by commas. Each key is followed by a colon `:` and the value: +A dictionary is another built-in data type in Python. A dictionary is a collection of data in the form of *key*-*value* pairs. Dictionaries are defined with curly braces (`{}`) and they contain key-value pairs separated by commas. Each key is followed by a colon (`:`) and the value: ```py {'amount': 50.0, 'category': 'Food'} @@ -19,10 +19,20 @@ Create a dictionary with a key `'amount'` and value of the `amount` parameter an # --hints-- -You should have `expenses.append({'amount': amount})` in your function. +You should pass a dictionary as the argument to the `.append()` method. ```js -assert.match(code, /^\s+expenses\.append\s*\(\s*\{\s*("|')amount\1\s*:\s*amount\s*\}\s*\)/m) +({ test: () => assert(runPython(` +import ast +node = _Node(_code).find_function("add_expense").find_calls("append")[0].find_call_args() +len(node) == 1 and isinstance(node[0].tree, ast.Dict) +`)) }) +``` + +You should pass `{'amount': amount}` as the argument to the `.append()` method. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("add_expense").has_stmt("expenses.append({'amount': amount})")`)) }) ``` # --seed-- diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658225d560369446ece5518b.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658225d560369446ece5518b.md index 510a44b67ab..721a796db68 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658225d560369446ece5518b.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658225d560369446ece5518b.md @@ -11,10 +11,20 @@ Add another key-value pair to the dictionary you are appending to the `expense` # --hints-- -You should have `expenses.append({'amount': amount, 'category': category})` in your code. +You should add a second key-value pair to the dictionary you are passing as the argument to the `.append()` method. ```js -assert.match(code, /^\s+expenses\.append\s*\(\s*\{\s*("|')amount\1\s*:\s*amount\s*,\s*("|')category\2\s*:\s*category\s*\}\s*\)/m) +({ test: () => assert(runPython(` +import ast +node = _Node(_code).find_function("add_expense").find_calls("append")[0].find_call_args() +len(node) == 1 and isinstance(node[0].tree, ast.Dict) and len(node[0].tree.keys) == 2 +`)) }) +``` + +You should pass `{'amount': amount, 'category': category}` as the argument to the `.append()` method. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("add_expense").has_stmt("expenses.append({'amount': amount, 'category': category})")`)) }) ``` # --seed-- diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582267ef39f5047411c1743.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582267ef39f5047411c1743.md index 3b14ff2cf43..75485fdd124 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582267ef39f5047411c1743.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582267ef39f5047411c1743.md @@ -7,7 +7,7 @@ dashedName: step-6 # --description-- -Start by defining a function named `print_expenses` that takes one parameter `expenses`. This function will later be used to display each expense in your list. +Next, define a function named `print_expenses` that takes one parameter `expenses`. This function will later be used to display each expense in your list. Fill the body of your new function with a `pass` statement. diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822773f4c60a479ec89f66.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822773f4c60a479ec89f66.md index d83045363fe..46a26e45ab9 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822773f4c60a479ec89f66.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822773f4c60a479ec89f66.md @@ -11,10 +11,22 @@ Inside the `print_expenses` function, create a `for` loop that iterates over eac # --hints-- -You should have `for expense in expenses:` in your `print_expenses` function. Remember to use `pass` within the loop body. +You should create a `for` loop that iterates over `expenses` in your `print_expenses` function. Remember to use `pass` within the loop body. ```js -({ test: () => assert.match(code, /for\s+expense\s+in\s+expenses\s*:/ ) }) +({ test: () => assert(runPython(`_Node(_code).find_function("print_expenses").find_for_loops()[0].find_for_iter().is_equivalent("expenses")`)) }) +``` + +You should use `expense` as the loop variable. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("print_expenses").find_for_loops()[0].find_for_vars().is_equivalent("expense")`)) }) +``` + +You should have `pass` only inside your loop body. + +```js +({ test: () => assert.isFalse(runPython(`_Node(_code).find_function("print_expenses").has_pass()`)) }) ``` # --seed-- diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822934c8a0454803e3ef12.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822934c8a0454803e3ef12.md index 4eb07ae618f..d8e1f7d2e9f 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822934c8a0454803e3ef12.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822934c8a0454803e3ef12.md @@ -9,14 +9,20 @@ dashedName: step-8 Next, you are going to display the details for each expense. -Inside the `for` loop, replace `pass` with a `print()` call and pass it the following f-string: `f'Amount: {expense}, Category: {expense}'`. Leave the placeholders empty for now. +Inside the `for` loop, replace `pass` with a `print()` call and pass it the following f-string: `f'Amount: {expense}, Category: {expense}'`. # --hints-- -You should have `print(f'Amount: {expense}, Category: {expense}')` in your `for` loop. +You should print `f'Amount: {expense}, Category: {expense}'` in your `for` loop. ```js -({ test: () => assert.match(code, /^\s+print\s*\(\s*f("|')Amount: \{\s*expense\s*\}, Category: \{\s*expense\s*\}\1\s*\)/m) }) +({ test: () => assert(runPython(`_Node(_code).find_function("print_expenses").find_for_loops()[0].has_call("print(f'Amount: {expense}, Category: {expense}')")`)) }) +``` + +You should not have `pass` inside your loop body. + +```js +({ test: () => assert.isFalse(runPython(`_Node(_code).find_function("print_expenses").find_for_loops()[0].find_bodies()[0].has_pass()`)) }) ``` # --seed-- diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822bd82d708c4895080c35.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822bd82d708c4895080c35.md index 7389641e58b..3fa3fb568b9 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822bd82d708c4895080c35.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822bd82d708c4895080c35.md @@ -7,7 +7,12 @@ dashedName: step-9 # --description-- -You can access values in a dictionary through its keys. You need to use the bracket notation and include the key between the square brackets: +In Python, an important thing to know is that the same type of quote used to define a string cannot be used inside it. For example, the string `'I'm a string!'` is not valid. To use the single quote inside that string you should either: + +- Escape the quote by prepending a backlash to it: `'I\'m a string!'` +- Or use double quotes to define the string: `"I'm a string!"` (preferred). + +You can access values in a dictionary through its keys. You need to use bracket notation and include the key between the square brackets: ```py my_dict = {'amount': 50.0, 'category': 'Food'} diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823040bdb32949d4c1a96f.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823040bdb32949d4c1a96f.md index 3dfe6dd193a..ab3e2f9fc07 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823040bdb32949d4c1a96f.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823040bdb32949d4c1a96f.md @@ -7,7 +7,9 @@ dashedName: step-10 # --description-- -You will need a function to calculate the total amount of expenses. Define a function named `total_expenses` that takes one parameter `expenses`. Fill the function body with a `pass` statement for now. +You will need a function to calculate the total amount of expenses. + +Define a function named `total_expenses` that takes one parameter `expenses`. Fill the function body with a `pass` statement for now. # --hints-- @@ -21,7 +23,7 @@ You should define a function named `total_expenses`. }) ``` -Your`total_expenses` function should take a single `expenses` parameter. +Your `total_expenses` function should take a single `expenses` parameter. ```js ({ test: () => assert(runPython(` diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582324b5d37fe4b622bc3c0.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582324b5d37fe4b622bc3c0.md index 92fdc0d0771..6e9189ed3f0 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582324b5d37fe4b622bc3c0.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582324b5d37fe4b622bc3c0.md @@ -13,14 +13,22 @@ Lambda functions are brief, anonymous functions in Python, ideal for simple, one lambda x: expr ``` -In the example above, `x` is a parameter to be used in the expression `expr`. Create a `test` variable and assign it a lambda function that takes an `x` parameter and returns `x * 2`. +In the example above, `x` represents a parameter to be used in the expression `expr`, and it acts just like any parameter in a traditional function. `expr` is the expression that gets evaluated and returned when the lambda function is called. + +Create a variable named `test` and assign it a lambda function that takes an `x` parameter and returns `x * 2`. # --hints-- -You should have `test = lambda x: x * 2` in your code. +You should declare a variable named `test`. ```js -({ test: () => assert.match(code,/^test\s*=\s*lambda\s+x\s*:\s*x\s*\*\s*2/m)}) +({ test: () => assert(runPython(`_Node(_code).has_variable("test")`))}) +``` + +You should assign `lambda x: x * 2` to your `test` variable. + +```js +({ test: () => assert(runPython(`_Node(_code).find_variable("test").is_equivalent("test = lambda x: x * 2")`))}) ``` # --seed-- diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823634a308cb4d6bcc5fa6.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823634a308cb4d6bcc5fa6.md index 9f673977231..59eb3e3c77b 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823634a308cb4d6bcc5fa6.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823634a308cb4d6bcc5fa6.md @@ -13,9 +13,11 @@ Lambda functions can be valuably combined with the `map()` function, which execu map(lambda x: x * 2, [1, 2, 3]) ``` +The function to execute is passed as the first argument, and the iterable is passed as the second argument. + The result of the example above would be `[2, 4, 6]`, where each item in the list passed to `map()` has been doubled by the action of the lambda function. -Modify your `print()` call to print the result of calling `map()` with `test` as the first argument, and `[2, 3, 5, 8]` as the second argument. +Modify your `print()` call to print the result of calling `map()` with `test` as the first argument, and `[2, 3, 5, 8]` as the second argument. You won't be able to see a readable output yet. # --hints-- diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md index 45d487652e1..d9226ae6d34 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md @@ -1,15 +1,15 @@ --- id: 658238f7604f154ea9a23e1e -title: Step 14 +title: Step 15 challengeType: 20 -dashedName: step-14 +dashedName: step-15 --- # --description-- The `sum()` function returns the sum of the items in the iterable which is passed as its argument. You are going to use `sum()` together with `map()` and `lambda` functions to get the total amount of expenses. -For now, make a little test and modify your current `print()` call by passing `sum(map(test, [2, 3, 5, 8]))` as the argument. +For now, make a little test and modify your current `print()` call replacing the `list()` call with a call to the `sum()` function passing it the current `map()` call as the argument. # --hints-- @@ -36,7 +36,7 @@ def total_expenses(expenses): --fcc-editable-region-- test = lambda x: x * 2 -print(map(test, [2, 3, 5, 8])) +print(list(map(test, [2,3,5,8]))) --fcc-editable-region-- expenses = [] diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md index 9d374a285ed..c7358d25594 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md @@ -1,28 +1,22 @@ --- id: 65823b0167fd894f4a7ea60a -title: Step 15 +title: Step 16 challengeType: 20 -dashedName: step-15 +dashedName: step-16 --- # --description-- -Next, you are going to implement the same logic to the `total_expenses` function. +Next, you are going to implement the same logic within the `total_expenses` function. For now, delete both the `test` function and the `print()` call. # --hints-- -You should delete your `test` variable. +You should delete your `test` variable and the related `print()` call. ```js -({ test: () => assert.notMatch(code, /test\s*=/) }) -``` - -You should delete your `print(sum(map(test, [2, 3, 5, 8])))` call. - -```js -({ test: () => assert.notMatch(code, /print\s*\(\s*sum/) }) +({ test: () => assert.isFalse(runPython(`_Node(_code).has_variable("test")`)) }) ``` # --seed-- diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md index d4a2f8399d4..b056b0bb531 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md @@ -1,27 +1,28 @@ --- id: 65823bbbdb4eaa4f9d20a0fb -title: Step 16 +title: Step 17 challengeType: 20 -dashedName: step-16 +dashedName: step-17 --- # --description-- -Within your `total_expenses` function, replace `pass` with a `lambda` function. Use `expense` as the parameter and return the value of the `'amount'` key in the `expense` dictionary. +In the `total_expenses` function, you'll now integrate a lambda function. Replace `pass` with a lambda function that has `expense` as its parameter. + +`expense` is expected to be a dictionary, and your lambda function should return the value of the `'amount'` key in the `expense` dictionary. # --hints-- -You should have `lambda expense: expense['amount']` in your `total_expenses` function. +You should create a `lambda` function that uses the parameter `expense` and returns `expense['amount']` in your `total_expenses` function. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "total_expenses"); - const {function_body} = foo; - assert(function_body.match(/^\s+lambda\s+expense\s*:\s*expense\s*\[\s*("|')amount\1\s*\]/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("total_expenses").has_stmt("lambda expense: expense['amount']")`)) }) +``` + +You should not have `pass` in your `total_expenses` function. + +```js +({ test: () => assert.isFalse(runPython(`_Node(_code).find_function("total_expenses").has_pass()`)) }) ``` # --seed-- diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md index 8a3db21c131..9c4390b4669 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md @@ -1,8 +1,8 @@ --- id: 65823cfc74aa564ffc460489 -title: Step 17 +title: Step 18 challengeType: 20 -dashedName: step-17 +dashedName: step-18 --- # --description-- @@ -11,17 +11,22 @@ Now, call `map()` passing your `lambda` function as the first argument and the ` # --hints-- -You should have `map(lambda expense: expense['amount'], expenses)` in your code. +You should call the `map()` function inside the `total_expenses` function. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "total_expenses"); - const {function_body} = foo; - assert(function_body.match(/^\s+map\s*\(\s*lambda\s+expense\s*:\s*expense\s*\[\s*("|')amount\1\s*\]\s*,\s*expenses\s*\)/m)); - } -}) +({ test: () => assert(runPython(`len(_Node(_code).find_function("total_expenses").find_calls("map")) == 1`)) }) +``` + +You should pass your `lambda` function as the first argument to the `map()` call. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("total_expenses").find_calls("map")[0].find_call_args()[0].is_equivalent("lambda expense: expense['amount']")`)) }) +``` + +You should pass the `expenses` list as the second argument to the `map()` call. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("total_expenses").find_calls("map")[0].find_call_args()[1].is_equivalent("expenses")`)) }) ``` # --seed-- diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md index ad2613a1c8a..9ff07605fac 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md @@ -1,8 +1,8 @@ --- id: 65823dde36392f505a39f7c7 -title: Step 18 +title: Step 19 challengeType: 20 -dashedName: step-18 +dashedName: step-19 --- # --description-- @@ -11,17 +11,10 @@ Finally, pass your `map()` call to the `sum()` function to obtain the total expe # --hints-- -You should return `sum(map(lambda expense: expense['amount'], expenses))` from your `total_expenses` function. +You should call the `sum()` function passing it your current `map()` call as the argument and return the result from your `total_expenses` function. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "total_expenses"); - const {function_body} = foo; - assert(function_body.match(/^\s+return\s+sum\s*\(\s*map\s*\(\s*lambda\s+expense\s*:\s*expense\s*\[\s*("|')amount\1\s*\]\s*,\s*expenses\s*\)\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("total_expenses").has_return("sum(map(lambda expense: expense['amount'], expenses))")`)) }) ``` # --seed-- diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md index 0da2a2b8b69..da444c85097 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md @@ -1,8 +1,8 @@ --- id: 65823e87c9741750a22085a7 -title: Step 19 +title: Step 20 challengeType: 20 -dashedName: step-19 +dashedName: step-20 --- # --description-- diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md index a9c3eadb188..92b7c92c01d 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md @@ -1,27 +1,26 @@ --- id: 65823ff0d4b991510fade1a8 -title: Step 20 +title: Step 21 challengeType: 20 -dashedName: step-20 +dashedName: step-21 --- # --description-- -Within the `filter_expenses_by_category` function, replace `pass` with a `lambda` function. Use `expense` as the parameter and return the comparison between the value of the `'category'` key of the `expense` dictionary and `category`. +Within the `filter_expenses_by_category` function, replace `pass` with a `lambda` function. Use `expense` as the parameter and return the comparison between the value of the `'category'` key of the `expense` dictionary and `category` using the equality operator. # --hints-- -You should have `lambda expense: expense['category'] == category` inside the `filter_expenses_by_category` function. +You should create a `lambda` function that uses a parameter named `expense` and returns the expression `expense['category'] == category` inside the `filter_expenses_by_category` function. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "filter_expenses_by_category"); - const {function_body} = foo; - assert(function_body.match(/^\s+lambda\s+expense\s*:\s*expense\s*\[\s*("|')category\1\s*\]\s*==\s*category/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("filter_expenses_by_category").has_stmt("lambda expense: expense['category'] == category")`)) }) +``` + +You should not have `pass` inside the `filter_expenses_by_category` function. + +```js +({ test: () => assert.isFalse(runPython(`_Node(_code).find_function("filter_expenses_by_category").has_pass()`)) }) ``` # --seed-- diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md index 9d8861e0fd9..fe47ee9f3f2 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md @@ -1,8 +1,8 @@ --- id: 65824111a09164518320088d -title: Step 21 +title: Step 22 challengeType: 20 -dashedName: step-21 +dashedName: step-22 --- # --description-- @@ -13,23 +13,30 @@ The `filter()` function allows you to select items from an iterable, such as a l filter(my_function, my_list) ``` -`filter()` returns an iterator in which the elements of `my_list` are included, for which `my_function` returns `True`. An iterator is a special object that enables you to iterate over the elements of a collection, like a list. +`filter()` takes a function as its first argument and an iterable as its second argument. It returns an iterator, which is a special object that enables you to iterate over the elements of a collection, like a list. + +The result of the example above is an iterator containing the elements of `my_list` for which `my_function` returns `True`. Within the `filter_expenses_by_category` function, call `filter()` passing the `lambda` function you wrote in the previous step as the first argument and the `expenses` list as the second argument. # --hints-- -You should have `filter(lambda expense: expense['category'] == category, expenses)` in your `filter_expenses_by_category` function. +You should call `filter()` inside the `filter_expenses_by_category` function. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "filter_expenses_by_category"); - const {function_body} = foo; - assert(function_body.match(/^\s+filter\s*\(\s*lambda\s+expense\s*:\s*expense\s*\[\s*("|')category\1\s*\]\s*==\s*category\s*,\s*expenses\s*\)/m)); - } -}) +({ test: () => assert(runPython(`len(_Node(_code).find_function("filter_expenses_by_category").find_calls("filter")) == 1`)) }) +``` + +You should pass `lambda expense: expense['category'] == category` as the first argument to the `filter()` call. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("filter_expenses_by_category").find_calls("filter")[0].find_call_args()[0].is_equivalent("lambda expense: expense['category'] == category")`)) }) +``` + +You should pass `expenses` as the second argument to the `filter()` call. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("filter_expenses_by_category").find_calls("filter")[0].find_call_args()[1].is_equivalent("expenses")`)) }) ``` # --seed-- diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md index 2154fc972fc..99c08f3e7d1 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md @@ -1,8 +1,8 @@ --- id: 658244fdf4b0265334711664 -title: Step 22 +title: Step 23 challengeType: 20 -dashedName: step-22 +dashedName: step-23 --- # --description-- @@ -14,14 +14,7 @@ Finally, return the result of the `filter()` call. You should return the result of the `filter()` call from your `filter_expenses_by_category` function. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "filter_expenses_by_category"); - const {function_body} = foo; - assert(function_body.match(/^\s+return\s+filter\s*\(\s*lambda\s+expense\s*:\s*expense\s*\[\s*("|')category\1\s*\]\s*==\s*category\s*,\s*expenses\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("filter_expenses_by_category").has_return("filter(lambda expense: expense['category'] == category, expenses)")`)) }) ``` # --seed-- diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md index 602e288b104..a2f8efceb9a 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md @@ -1,8 +1,8 @@ --- id: 65824561f3478e5371a33ae5 -title: Step 23 +title: Step 24 challengeType: 20 -dashedName: step-23 +dashedName: step-24 --- # --description-- @@ -19,6 +19,8 @@ You should define a function named `main()` without parameters. ({ test: () => assert(runPython(` import inspect inspect.isfunction(main) + sig = str(inspect.signature(main)) + sig == '()' `)) }) ``` @@ -26,12 +28,7 @@ You should define a function named `main()` without parameters. You should move the `expenses` list inside the `main()` function body. ```js -({ test: () => assert(runPython(` - import inspect - sig = str(inspect.signature(main)) - sig == '()' - `)) -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_body().is_equivalent("expenses = []")`)) }) ``` # --seed-- diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md index 3cd8e3642fd..5471bb36c92 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md @@ -1,8 +1,8 @@ --- id: 658246c28575d653d1f89b59 -title: Step 24 +title: Step 25 challengeType: 20 -dashedName: step-24 +dashedName: step-25 --- # --description-- @@ -18,30 +18,16 @@ Below the `expenses` list, create a `while` loop. Use `True` for the condition, # --hints-- -You should have `while True:` in your `main()` function. +You should create a `while` loop using `True` as the condition within your `main()` function. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+while\s+True\s*:/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_conditions()[0].is_equivalent("True")`)) }) ``` -You should have `print('\nExpense Tracker')` in your `while` loop. +You should print `'\nExpense Tracker'` in your `while` loop. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+print\s*\(\s*("|')\\nExpense\s*Tracker\1\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_calls("print")[0].is_equivalent("print('\\\\nExpense Tracker')")`)) }) ``` # --seed-- diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md index 7bd3ed13946..97d773f5cb8 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md @@ -1,29 +1,26 @@ --- id: 65824872894f59546e3084e2 -title: Step 25 +title: Step 26 challengeType: 20 -dashedName: step-25 +dashedName: step-26 --- # --description-- The `while` loop you created in the previous step is an infinite loop that will allow the program to continuously present menu options until the user decides to exit. -After the `print()` call, add another one to print the string `'1. Add an expense'`. +After the `print()` call, add another `print()` call to print the string `'1. Add an expense'`. # --hints-- -You should have `print('1. Add an expense')` in your `while` loop. +You should print `'1. Add an expense'` within your `while` loop after the existing `print()` call. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+print\s*\(\s*("|')1\.\sAdd\san\sexpense\1\s*\)/m)); - } -}) +({ test: () => assert(runPython(` +call_lst = _Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_calls("print") +test_lst = ["print('\\\\nExpense Tracker')", "print('1. Add an expense')"] +all(call_lst[n].is_equivalent(i) for n, i in enumerate(test_lst)) +`)) }) ``` # --seed-- diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md index 93ee461978a..bee24b42de5 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md @@ -1,8 +1,8 @@ --- id: 65824a1b16631c54fa524154 -title: Step 26 +title: Step 27 challengeType: 20 -dashedName: step-26 +dashedName: step-27 --- # --description-- @@ -11,17 +11,14 @@ Next, add another `print()` call and pass the string `'2. List all expenses'`. # --hints-- -You should have `print('2. List all expenses')` in your `while` loop. +You should print `'2. List all expenses'` in your `while` loop after the existing `print()` calls. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+print\s*\(\s*("|')2\.\sList\sall\sexpenses\1\s*\)/m)); - } -}) +({ test: () => assert(runPython(` +call_lst = _Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_calls("print") +test_lst = ["print('\\\\nExpense Tracker')", "print('1. Add an expense')", "print('2. List all expenses')"] +all(call_lst[n].is_equivalent(i) for n, i in enumerate(test_lst)) +`)) }) ``` # --seed-- diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md index c374d62d60d..132862fc6fe 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md @@ -1,53 +1,44 @@ --- id: 65824c7b4e2da85597693dcf -title: Step 27 +title: Step 28 challengeType: 20 -dashedName: step-27 +dashedName: step-28 --- # --description-- -Provide the other menu options by printing the following three strings in your `while` loop: `'3. Show total expenses'`, `'4. Filter expenses by category'`, and `'5. Exit'`. +Provide the other menu options by printing the following three strings in your `while` loop: `'3. Show total expenses'`, `'4. Filter expenses by category'`, and `'5. Exit'`. Keep adding the `print()` calls in order. # --hints-- You should have `print('3. Show total expenses')` in your `while` loop. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+print\s*\(\s*("|')3\.\sShow\stotal\sexpenses\1\s*\)/m)); - } -}) +({ test: () => assert(runPython(` +call_lst = _Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_calls("print") +test_lst = ["print('\\\\nExpense Tracker')", "print('1. Add an expense')", "print('2. List all expenses')", "print('3. Show total expenses')"] +all(call_lst[n].is_equivalent(i) for n, i in enumerate(test_lst)) +`)) }) ``` You should have `print('4. Filter expenses by category')` in your `while` loop. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+print\s*\(\s*("|')4\.\sFilter\sexpenses\sby\scategory\1\s*\)/m)); - } -}) +({ test: () => assert(runPython(` +call_lst = _Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_calls("print") +test_lst = ["print('\\\\nExpense Tracker')", "print('1. Add an expense')", "print('2. List all expenses')", "print('3. Show total expenses')", "print('4. Filter expenses by category')"] +all(call_lst[n].is_equivalent(i) for n, i in enumerate(test_lst)) +`)) }) ``` You should have `print('5. Exit')` in your `while` loop. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+print\s*\(\s*("|')5\.\sExit\1\s*\)/m)); - } -}) +({ test: () => assert(runPython(` +call_lst = _Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_calls("print") +test_lst = ["print('\\\\nExpense Tracker')", "print('1. Add an expense')", "print('2. List all expenses')", "print('3. Show total expenses')", "print('4. Filter expenses by category')", "print('5. Exit')"] +all(call_lst[n].is_equivalent(i) for n, i in enumerate(test_lst)) +`)) }) ``` # --seed-- diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md index b7a6a5a4592..392024966fb 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md @@ -1,8 +1,8 @@ --- id: 65824dfdb6815d563b2d3256 -title: Step 28 +title: Step 29 challengeType: 20 -dashedName: step-28 +dashedName: step-29 --- # --description-- @@ -13,17 +13,18 @@ Inside your `while` loop, call the `input()` function passing the string `'Enter # --hints-- -You should have `choice = input('Enter your choice: ')` in your `while` loop. +You should declare a variable named `choice` within your `while` loop. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+choice\s*=\s*input\s*\(\s*("|')Enter\syour\schoice:\s\1\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].has_variable("choice") +`)) }) +``` + +You should assign the result of the `input()` function, with the string `'Enter your choice: '` as its argument, to your `choice` variable. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_variable("choice").is_equivalent("choice = input('Enter your choice: ')") +`)) }) ``` # --seed-- diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md index 34dbde9fb81..240d01654e0 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md @@ -1,8 +1,8 @@ --- id: 6582507654b3ed5712341382 -title: Step 29 +title: Step 30 challengeType: 20 -dashedName: step-29 +dashedName: step-30 --- # --description-- @@ -15,30 +15,27 @@ Inside the `if` statement body, declare a variable `amount` and assign it an emp # --hints-- -You should have `if choice == '1':` in your `while` loop: +You should create an `if` statement that checks if `choice` is equal to `'1'` in your `while` loop. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+if\s+choice\s*==\s*("|')1\1\s*:/m)); - } -}) +({ test: () => assert(runPython(` +cond = _Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_conditions()[0] +cond.is_equivalent("choice == '1'") or cond.is_equivalent("'1' == choice") +`)) }) ``` -You should have `amount = input()` in your `if` statement body: +You should declare a variable named `amount` in your `if` statement body. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+if\s+choice\s*==\s*("|')1\1\s*:\s*amount\s*=\s*input\s*\(\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[0].has_variable("amount") +`)) }) +``` + +You should assign an empty `input()` call to your `amount` variable. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[0].find_variable("amount").is_equivalent("amount = input()") +`)) }) ``` # --seed-- diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md index 83de6165853..6d76794bd32 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md @@ -1,8 +1,8 @@ --- id: 658252f6b1526d57b103d48a -title: Step 30 +title: Step 31 challengeType: 20 -dashedName: step-30 +dashedName: step-31 --- # --description-- @@ -13,17 +13,11 @@ Pass the string `'Enter amount: '` to your empty `input()` call, so you can stor # --hints-- -You should have `amount = input('Enter amount: ')` in your `if` statement. +You should pass `'Enter amount: '` to the `input()` call assigned to the `amount` variable. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+if\s+choice\s*==\s*("|')1\1\s*:\s*amount\s*=\s*input\s*\(\s*("|')Enter amount:\s\2\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[0].find_variable("amount").is_equivalent("amount = input('Enter amount: ')") +`)) }) ``` # --seed-- @@ -44,7 +38,6 @@ def total_expenses(expenses): def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) ---fcc-editable-region-- def main(): expenses = [] while True: @@ -56,7 +49,7 @@ def main(): print('5. Exit') choice = input('Enter your choice: ') - +--fcc-editable-region-- if choice == '1': amount = input() --fcc-editable-region-- diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md index 3ac10338242..8818d086821 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md @@ -1,8 +1,8 @@ --- id: 658254db6e12485a48130f57 -title: Step 31 +title: Step 32 challengeType: 20 -dashedName: step-31 +dashedName: step-32 --- # --description-- @@ -13,17 +13,11 @@ Pass `input('Enter amount: ')` to the `float()` function. # --hints-- -You should have `amount = float(input('Enter amount: '))` in your `if` statement. +You should pass `input('Enter amount: ')` to the `float()` function in the assignment of `amount`. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+if\s+choice\s*==\s*("|')1\1\s*:\s*amount\s*=\s*float\s*\(\s*input\s*\(\s*("|')Enter\samount:\s\2\s*\)\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[0].find_variable("amount").is_equivalent("amount = float(input('Enter amount: '))") +`)) }) ``` # --seed-- diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md index 4a24dd06ee0..520834f9bfc 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md @@ -1,27 +1,26 @@ --- id: 658255d5f955175b270f251d -title: Step 32 +title: Step 33 challengeType: 20 -dashedName: step-32 +dashedName: step-33 --- # --description-- -Inside your `if` statement, create a variable `category` to store the expense category. Assign it `input('Enter category: ')`. +Inside your `if` statement, create a variable named `category` to store the expense category. Assign it a call to `input()` and use the `'Enter category: '` as the argument. # --hints-- -You should have `category = input('Enter category: ')` in your `if` statement. +You should declare a variable named `category` in your `if` statement. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+if\s+choice\s*==\s*("|')1\1\s*:\s*amount\s*=\s*float\s*\(\s*input\s*\(\s*("|')Enter\samount:\s\2\s*\)\s*\)\s*category\s*=\s*input\s*\(\s*("|')Enter\scategory:\s\3\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[0].has_variable("category")`)) }) +``` + +You should assign `input('Enter category: ')` to your `category` variable. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[0].find_variable("category").is_equivalent("category = input('Enter category: ')")`)) }) ``` # --seed-- diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md index 588f91859d2..2923664b6db 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md @@ -1,13 +1,13 @@ --- id: 6582575b8089f85b8b92d7c8 -title: Step 33 +title: Step 34 challengeType: 20 -dashedName: step-33 +dashedName: step-34 --- # --description-- -After getting the expense details, you need to call the `add_expense` function to add the new expense to the `expenses` list. +Once you have the expense details, you need to call the `add_expense` function to add the new expense to the `expenses` list. After getting the `amount` and `category` using `input()`, call the `add_expense` function, passing three arguments: `expenses`, `amount` and `category`. @@ -17,17 +17,22 @@ After getting the `amount` and `category` using `input()`, call the `add_expense # --hints-- -You should have `add_expense(expenses, amount, category)` in your `if` statement. +You should call the `add_expense()` function within your `if` statement. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+if\s+choice\s*==\s*("|')1\1\s*:\s*amount\s*=\s*float\s*\(\s*input\s*\(\s*("|')Enter\samount:\s\2\s*\)\s*\)\s*category\s*=\s*input\s*\(\s*("|')Enter\scategory:\s\3\s*\)\s*add_expense\s*\(\s*expenses\s*,\s*amount\s*,\s*category\s*\)/m)); - } -}) +({ test: () => assert(runPython(`len(_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[0].find_calls("add_expense")) == 1`)) }) +``` + +You should pass three arguments to your `add_expense()` call: `expenses`, `amount`, and `category`. The order matters. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[0].has_call("add_expense(expenses, amount, category)")`)) }) +``` + +Your `add_expense()` call should come after the assignment of `amount` and `category`. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[0].is_equivalent("amount = float(input('Enter amount: '))\\ncategory = input('Enter category: ')\\nadd_expense(expenses, amount, category)")`)) }) ``` # --seed-- diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md index ef5f5a90136..50cb2f6a557 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md @@ -1,42 +1,31 @@ --- id: 658258c0e5fbe85c14c060cf -title: Step 34 +title: Step 35 challengeType: 20 -dashedName: step-34 +dashedName: step-35 --- # --description-- -To list all expenses, you can use an `elif` statement after an `if` statement. The `elif` checks additional conditions and only works following an `if` statement. +To list all expenses, you can use an `elif` clause after an `if` statement. The `elif` checks additional conditions and only works following an `if` statement. -Create an `elif` statement to check if the user's choice equals the string `2`. Inside the `elif` statement, print the string `'\nAll Expenses:'`. +Create an `elif` clause to check if the user's choice equals the string `'2'`. Inside the `elif` clause, print the string `'\nAll Expenses:'`. # --hints-- -You should have `elif choice == '2':` after your `if` statement. +You should create an `elif` clause that checks that `choice` is equal to `'2'` after your `if` statement. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+elif\s+choice\s*==\s*("|')2\1\s*:/m)); - } -}) +({ test: () => assert(runPython(` +cond = _Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_conditions()[1] +cond.is_equivalent("choice == '2'") or cond.is_equivalent("'2' == choice") +`)) }) ``` -You should have `print('\nAll Expenses:')` inside your `elif` statement. +You should print `'\nAll Expenses:'` inside your `elif` clause. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+elif\s+choice\s*==\s*("|')2\1\s*:\s*print\s*\(\s*("|')\\nAll\sExpenses:\2\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[1].has_call("print('\\\\nAll Expenses:')")`)) }) ``` # --seed-- diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md index 53051c73dc4..28de93f6f77 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md @@ -1,8 +1,8 @@ --- id: 65825a9520a0795c8afbef50 -title: Step 35 +title: Step 36 challengeType: 20 -dashedName: step-35 +dashedName: step-36 --- # --description-- @@ -11,17 +11,16 @@ After the `print()` call, call the `print_expenses` function to display all the # --hints-- -You should have `print_expenses(expenses)` in your `elif` statement. +You should call the `print_expenses()` function within your `elif` clause. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+elif\s+choice\s*==\s*("|')2\1\s*:\s*print\s*\(\s*("|')\\nAll\sExpenses:\2\s*\)\s*print\s*_expenses\s*\(\s*expenses\s*\)/m)); - } -}) +({ test: () => assert(runPython(`len(_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[1].find_calls("print_expenses")) == 1`)) }) +``` + +You should pass the `expenses` list as the argument to your `print_expenses()` call. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[1].has_call("print_expenses(expenses)")`)) }) ``` # --seed-- diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md index f4bedf6c887..1322922a208 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md @@ -1,8 +1,8 @@ --- id: 65825b758fe85a5cebabc8c5 -title: Step 36 +title: Step 37 challengeType: 20 -dashedName: step-36 +dashedName: step-37 --- # --description-- @@ -13,30 +13,19 @@ If it's true, it means the user wants to see the total expenses. So call `print( # --hints-- -You should have `elif choice == '3':` in your code. +You should create an `elif` clause that checks if `choice == '3'`. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert.match(function_body, /\s+elif\s+choice\s*==\s*("|')3\1\s*:/); - } -}) +({ test: () => assert(runPython(` +cond = _Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_conditions()[2] +cond.is_equivalent("choice == '3'") or cond.is_equivalent("'3' == choice") +`)) }) ``` -You should have `print('\nTotal Expenses: ', total_expenses(expenses))` in your `elif` statement. +You should print `'\nTotal Expenses: ', total_expenses(expenses)` in your new `elif` clause. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+elif\s+choice\s*==\s*("|')3\1\s*:\s*print\s*\(\s*("|')\\nTotal\sExpenses:\s\2\s*,\s*total_expenses\s*\(\s*expenses\s*\)\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[2].has_call("print('\\\\nTotal Expenses: ', total_expenses(expenses))")`)) }) ``` # --seed-- diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md index d355dc243eb..9436b4f73c1 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md @@ -1,40 +1,35 @@ --- id: 65825cda2668995d5168e37c -title: Step 37 +title: Step 38 challengeType: 20 -dashedName: step-37 +dashedName: step-38 --- # --description-- -Create another `elif` statement that checks if `choice == '4'`. Inside the new `elif`, create a variable `category` and assign it `input('Enter category to filter: ')` to filter the expense category. +Create another `elif` clause that checks if `choice == '4'`. Inside the new `elif`, create a variable `category` and assign it `input('Enter category to filter: ')` to filter the expense category. # --hints-- -You should have `elif choice == '4':` in your code. +You should create an `elif` clause that checks if `choice == '4'`. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+elif\s+choice\s*==\s*("|')4\1\s*:/m)); - } -}) +({ test: () => assert(runPython(` +cond = _Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_conditions()[3] +cond.is_equivalent("choice == '4'") or cond.is_equivalent("'4' == choice") +`)) }) ``` -You should have `category = input('Enter category to filter: ')` in your new `elif` statement. +You should declared a variable named `category` in your new `elif` clause. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+elif\s+choice\s*==\s*("|')4\1\s*:\s*category\s*=\s*input\s*\(\s*("|')Enter\scategory\sto\sfilter:\s\2\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[3].has_variable("category")`)) }) +``` + +You should assign `input('Enter category to filter: ')` to your `category` variable. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[3].find_variable("category").is_equivalent("category = input('Enter category to filter: ')")`)) }) ``` # --seed-- diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md index 216df85146a..c771cc30551 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md @@ -1,8 +1,8 @@ --- id: 65825e96b5db5f5dee6bf57c -title: Step 38 +title: Step 39 challengeType: 20 -dashedName: step-38 +dashedName: step-39 --- # --description-- @@ -11,17 +11,10 @@ After getting the category, print the following f-string `f'\nExpenses for {cate # --hints-- -You should print `f'\nExpenses for {category}:'` inside the `elif` statement. +You should print `f'\nExpenses for {category}:'` after the assignment of `category`. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+elif\s+choice\s*==\s*("|')4\1\s*:\s*category\s*=\s*input\s*\(\s*("|')Enter\scategory\sto\sfilter:\s\2\s*\)\s*print\s*\(\s*f("|')\\nExpenses for \{\s*category\s*\}:\3\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[3].is_equivalent("category = input('Enter category to filter: ')\\nprint(f'\\\\nExpenses for {category}:')")`)) }) ``` # --seed-- diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md index 8f058be3798..5a529fbe4bd 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md @@ -1,8 +1,8 @@ --- id: 6582601b2987045e8e7da994 -title: Step 39 +title: Step 40 challengeType: 20 -dashedName: step-39 +dashedName: step-40 --- # --description-- @@ -11,17 +11,22 @@ After your `print()` call, you need to filter the expenses and print the filtere # --hints-- -You should have `expenses_from_category = filter_expenses_by_category(expenses, category)` in your `elif` statement. +You should declare a variable named `expenses_from_category` in your `elif` clause. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+elif\s+choice\s*==\s*("|')4\1\s*:\s*category\s*=\s*input\s*\(\s*("|')Enter\scategory\sto\sfilter:\s\2\s*\)\s*print\s*\(\s*f("|')\\nExpenses for \{\s*category\s*\}:\3\s*\)\s*expenses_from_category\s*=\s*filter_expenses_by_category\s*\(\s*expenses\s*,\s*category\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[3].has_variable("expenses_from_category")`)) }) +``` + +You should call `filter_expenses_by_category()` passing `expenses` and `category` as the arguments and assign it to your `expenses_from_category` variable. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[3].find_variable("expenses_from_category").is_equivalent("expenses_from_category = filter_expenses_by_category(expenses, category)")`)) }) +``` + +Your `expenses_from_category` variable should come after the `print()` call. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[3].is_equivalent("category = input('Enter category to filter: ')\\nprint(f'\\\\nExpenses for {category}:')\\nexpenses_from_category = filter_expenses_by_category(expenses, category)")`)) }) ``` # --seed-- diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md index 77c98c73e8e..746e7779537 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md @@ -1,27 +1,26 @@ --- id: 6582622cb6c11a5f4c5d79b4 -title: Step 40 +title: Step 41 challengeType: 20 -dashedName: step-40 +dashedName: step-41 --- # --description-- -Still within the `elif` statement, pass `expenses_from_category` iterator to a `print_expenses` call. +Still within the `elif` clause, pass the `expenses_from_category` iterator to a `print_expenses` call. # --hints-- -You should have `print_expenses(expenses_from_category)` in your code. +You should call `print_expenses()` passing `expenses_from_category` as the argument in your `elif` clause. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+elif\s+choice\s*==\s*("|')4\1\s*:\s*category\s*=\s*input\s*\(\s*("|')Enter\scategory\sto\sfilter:\s\2\s*\)\s*print\s*\(\s*f("|')\\nExpenses for \{\s*category\s*\}:\3\s*\)\s*expenses_from_category\s*=\s*filter_expenses_by_category\s*\(\s*expenses\s*,\s*category\s*\)\s*print_expenses\s*\(\s*expenses_from_category\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[3].has_call("print_expenses(expenses_from_category)")`)) }) +``` + +Your `print_expenses()` call should come after the `expenses_from_category` variable. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[3].is_equivalent("category = input('Enter category to filter: ')\\nprint(f'\\\\nExpenses for {category}:')\\nexpenses_from_category = filter_expenses_by_category(expenses, category)\\nprint_expenses(expenses_from_category)")`)) }) ``` # --seed-- diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md index 1178193ba5f..76316b1ba48 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md @@ -1,42 +1,31 @@ --- id: 6582687859366a618424d84b -title: Step 41 +title: Step 42 challengeType: 20 -dashedName: step-41 +dashedName: step-42 --- # --description-- -To provide a way to exit the program, use another `elif` statement to check if `choice` equals the string `'5'`. +To provide a way to exit the program, use another `elif` clause to check if `choice` equals the string `'5'`. -Inside the new `elif` statement, print the string `'Exiting the program.'` to show that the program is terminating its execution. +Inside the new `elif` clause, print the string `'Exiting the program.'` to show that the program is terminating its execution. # --hints-- -You should have `elif choice == '5':` in your code. +You should create an `elif` clause that checks if `choice == '5'`. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+elif\s+choice\s*==\s*("|')5\1\s*:/m)); - } -}) +({ test: () => assert(runPython(` +cond = _Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_conditions()[4] +cond.is_equivalent("choice == '5'") or cond.is_equivalent("'5' == choice") +`)) }) ``` -You should print `'Exiting the program.'` in your new `elif` statement. +You should print `'Exiting the program.'` in your new `elif` clause. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+elif\s+choice\s*==\s*("|')5\1\s*:\s*print\s*\(\s*("|')Exiting\sthe\sprogram.\2\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[4].has_call("print('Exiting the program.')")`)) }) ``` # --seed-- diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md index 7829a742975..465c1008e5a 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md @@ -1,27 +1,20 @@ --- id: 65826a6e9d189a623141c726 -title: Step 42 +title: Step 43 challengeType: 20 -dashedName: step-42 +dashedName: step-43 --- # --description-- -Finally, to stop the execution of the `while` loop, add the `break` statement inside your last `elif` statement. +Finally, to stop the execution of the `while` loop, add the `break` statement inside your last `elif` clause. # --hints-- -You should have a `break` statement inside your last `elif`. +You should have a `break` statement after the `print()` call inside your last `elif` clause. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+break/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[4].is_equivalent("print('Exiting the program.')\\nbreak")`)) }) ``` # --seed-- diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md index e5f24e2b1f8..b8403971842 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md @@ -1,13 +1,15 @@ --- id: 65826af5b226a5628aa154b1 -title: Step 43 +title: Step 44 challengeType: 20 -dashedName: step-43 +dashedName: step-44 --- # --description-- -Finally, call your `main()` function, and try the expense tracker program. +Finally, call your `main()` function, and try the expense tracker program in the console. + +With that, the expense tracker project is complete! # --hints-- @@ -74,3 +76,58 @@ def main(): --fcc-editable-region-- ``` + +# --solutions-- + +```py +def add_expense(expenses, amount, category): + expenses.append({'amount': amount, 'category': category}) + +def print_expenses(expenses): + for expense in expenses: + print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') + +def total_expenses(expenses): + return sum(map(lambda expense: expense['amount'], expenses)) + +def filter_expenses_by_category(expenses, category): + return filter(lambda expense: expense['category'] == category, expenses) + + +def main(): + expenses = [] + while True: + print('\nExpense Tracker') + print('1. Add an expense') + print('2. List all expenses') + print('3. Show total expenses') + print('4. Filter expenses by category') + print('5. Exit') + + choice = input('Enter your choice: ') + + if choice == '1': + amount = float(input('Enter amount: ')) + category = input('Enter category: ') + add_expense(expenses, amount, category) + + elif choice == '2': + print('\nAll Expenses:') + print_expenses(expenses) + + elif choice == '3': + print('\nTotal Expenses: ', total_expenses(expenses)) + + elif choice == '4': + category = input('Enter category to filter: ') + print(f'\nExpenses for {category}:') + expenses_from_category = filter_expenses_by_category(expenses, category) + print_expenses(expenses_from_category) + + elif choice == '5': + print('Exiting the program.') + break + +main() + +``` diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826befd75db5632bd73df6.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826befd75db5632bd73df6.md deleted file mode 100644 index 5daa9a4d51a..00000000000 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826befd75db5632bd73df6.md +++ /dev/null @@ -1,145 +0,0 @@ ---- -id: 65826befd75db5632bd73df6 -title: Step 44 -challengeType: 20 -dashedName: step-44 ---- - -# --description-- - -You can use the `__name__` variable to determine if a Python script is being run as the main program or if it is being imported as a module (code written in another Python file). - -If the value of `__name__` is set to `'__main__'`, it implies that the current script is the main program, and not a module. - -As a final step, create an `if` statement to check if ` __name__ == '__main__'`, and move the `main()` call inside this block. - -With that, the expense tracker project is complete! - -# --hints-- - -You should have `if __name__ == '__main__':` in your code. - -```js -assert.match(code,/^if\s+__name__\s*==\s*("|')__main__\1\s*:/m); -``` - -Your `main()` call should be inside the `if` statement. - -```js -assert.match(code, /^if\s+__name__\s*==\s*("|')__main__\1\s*:\s*main\s*\(\s*\)/m); -``` - -# --seed-- - -## --seed-contents-- - -```py -def add_expense(expenses, amount, category): - expenses.append({'amount': amount, 'category': category}) - -def print_expenses(expenses): - for expense in expenses: - print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - -def total_expenses(expenses): - return sum(map(lambda expense: expense['amount'], expenses)) - -def filter_expenses_by_category(expenses, category): - return filter(lambda expense: expense['category'] == category, expenses) - - -def main(): - expenses = [] - while True: - print('\nExpense Tracker') - print('1. Add an expense') - print('2. List all expenses') - print('3. Show total expenses') - print('4. Filter expenses by category') - print('5. Exit') - - choice = input('Enter your choice: ') - - if choice == '1': - amount = float(input('Enter amount: ')) - category = input('Enter category: ') - add_expense(expenses, amount, category) - - elif choice == '2': - print('\nAll Expenses:') - print_expenses(expenses) - - elif choice == '3': - print('\nTotal Expenses: ', total_expenses(expenses)) - - elif choice == '4': - category = input('Enter category to filter: ') - print(f'\nExpenses for {category}:') - expenses_from_category = filter_expenses_by_category(expenses, category) - print_expenses(expenses_from_category) - - elif choice == '5': - print('Exiting the program.') - break - ---fcc-editable-region-- -main() ---fcc-editable-region-- -``` - - -# --solutions-- - -```py -def add_expense(expenses, amount, category): - expenses.append({'amount': amount, 'category': category}) - -def print_expenses(expenses): - for expense in expenses: - print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - -def total_expenses(expenses): - return sum(map(lambda expense: expense['amount'], expenses)) - -def filter_expenses_by_category(expenses, category): - return filter(lambda expense: expense['category'] == category, expenses) - - -def main(): - expenses = [] - while True: - print('\nExpense Tracker') - print('1. Add an expense') - print('2. List all expenses') - print('3. Show total expenses') - print('4. Filter expenses by category') - print('5. Exit') - - choice = input('Enter your choice: ') - - if choice == '1': - amount = float(input('Enter amount: ')) - category = input('Enter category: ') - add_expense(expenses, amount, category) - - elif choice == '2': - print('\nAll Expenses:') - print_expenses(expenses) - - elif choice == '3': - print('\nTotal Expenses: ', total_expenses(expenses)) - - elif choice == '4': - category = input('Enter category to filter: ') - print(f'\nExpenses for {category}:') - expenses_from_category = filter_expenses_by_category(expenses, category) - print_expenses(expenses_from_category) - - elif choice == '5': - print('Exiting the program.') - break - -if __name__ == '__main__': - main() - -``` diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/66314f2add0a8b57da5d6d91.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/66314f2add0a8b57da5d6d91.md new file mode 100644 index 00000000000..43669da4b07 --- /dev/null +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/66314f2add0a8b57da5d6d91.md @@ -0,0 +1,43 @@ +--- +id: 66314f2add0a8b57da5d6d91 +title: Step 14 +challengeType: 20 +dashedName: step-14 +--- + +# --description-- + +You should see something like `` printed on the console, which is the string representation of the map object returned by `map()`. + +To obtain a readable output you need to turn the map object into a list. Do it by passing the `map()` call as the argument to the `list()` function. + +# --hints-- + +You should pass the `map()` call as the argument to the `list()` function. + +```js +({ test: () => assert(runPython(`_Node(_code).has_call("print(list(map(test, [2,3,5,8])))")`)) }) +``` + +# --seed-- + +## --seed-contents-- + +```py +def add_expense(expenses, amount, category): + expenses.append({'amount': amount, 'category': category}) + +def print_expenses(expenses): + for expense in expenses: + print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') + +def total_expenses(expenses): + pass + +--fcc-editable-region-- +test = lambda x: x * 2 +print(map(test, [2, 3, 5, 8])) +--fcc-editable-region-- + +expenses = [] +``` diff --git a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md index 60ba679d3b5..4b40036a2f6 100644 --- a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md +++ b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md @@ -2,7 +2,7 @@ id: 658238f7604f154ea9a23e1e title: Paso 14 challengeType: 20 -dashedName: step-14 +dashedName: step-15 --- # --description-- diff --git a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md index e1d13b5dc42..596a67ce30b 100644 --- a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md +++ b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md @@ -2,7 +2,7 @@ id: 65823b0167fd894f4a7ea60a title: Paso 15 challengeType: 20 -dashedName: step-15 +dashedName: step-16 --- # --description-- diff --git a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md index 44d6692446d..503c48eda5f 100644 --- a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md +++ b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md @@ -2,7 +2,7 @@ id: 65823bbbdb4eaa4f9d20a0fb title: Paso 16 challengeType: 20 -dashedName: step-16 +dashedName: step-17 --- # --description-- diff --git a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md index c14302488a2..dded1c6d3fe 100644 --- a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md +++ b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md @@ -2,7 +2,7 @@ id: 65823cfc74aa564ffc460489 title: Paso 17 challengeType: 20 -dashedName: step-17 +dashedName: step-18 --- # --description-- diff --git a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md index 6089e18c010..3b1fef12c58 100644 --- a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md +++ b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md @@ -2,7 +2,7 @@ id: 65823dde36392f505a39f7c7 title: Paso 18 challengeType: 20 -dashedName: step-18 +dashedName: step-19 --- # --description-- diff --git a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md index a0f7c2e8690..89b1cecd78b 100644 --- a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md +++ b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md @@ -2,7 +2,7 @@ id: 65823e87c9741750a22085a7 title: Paso 19 challengeType: 20 -dashedName: step-19 +dashedName: step-20 --- # --description-- diff --git a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md index 78d8e942b1e..5ed5fe358f8 100644 --- a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md +++ b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md @@ -2,7 +2,7 @@ id: 65823ff0d4b991510fade1a8 title: Paso 20 challengeType: 20 -dashedName: step-20 +dashedName: step-21 --- # --description-- diff --git a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md index 169d3df7aae..3b0b0b1df6d 100644 --- a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md +++ b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md @@ -2,7 +2,7 @@ id: 65824111a09164518320088d title: Paso 21 challengeType: 20 -dashedName: step-21 +dashedName: step-22 --- # --description-- diff --git a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md index dee4a956f26..7380050508a 100644 --- a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md +++ b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md @@ -2,7 +2,7 @@ id: 658244fdf4b0265334711664 title: Paso 22 challengeType: 20 -dashedName: step-22 +dashedName: step-23 --- # --description-- diff --git a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md index 47698315d66..0e2d0a651cc 100644 --- a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md +++ b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md @@ -2,7 +2,7 @@ id: 65824561f3478e5371a33ae5 title: Paso 23 challengeType: 20 -dashedName: step-23 +dashedName: step-24 --- # --description-- diff --git a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md index 388663df27c..428006994a5 100644 --- a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md +++ b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md @@ -2,7 +2,7 @@ id: 658246c28575d653d1f89b59 title: Paso 24 challengeType: 20 -dashedName: step-24 +dashedName: step-25 --- # --description-- diff --git a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md index c0ddc3679e6..879ee460edc 100644 --- a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md +++ b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md @@ -2,7 +2,7 @@ id: 65824872894f59546e3084e2 title: Paso 25 challengeType: 20 -dashedName: step-25 +dashedName: step-26 --- # --description-- diff --git a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md index ad76a183580..ff7a6e82ce7 100644 --- a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md +++ b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md @@ -2,7 +2,7 @@ id: 65824a1b16631c54fa524154 title: Paso 26 challengeType: 20 -dashedName: step-26 +dashedName: step-27 --- # --description-- diff --git a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md index 2f049902625..9e76f4394ec 100644 --- a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md +++ b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md @@ -2,7 +2,7 @@ id: 65824c7b4e2da85597693dcf title: Paso 27 challengeType: 20 -dashedName: step-27 +dashedName: step-28 --- # --description-- diff --git a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md index 60e9338b06e..7098e9b0061 100644 --- a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md +++ b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md @@ -2,7 +2,7 @@ id: 65824dfdb6815d563b2d3256 title: Paso 28 challengeType: 20 -dashedName: step-28 +dashedName: step-29 --- # --description-- diff --git a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md index b67d227ed90..068323fd01c 100644 --- a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md +++ b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md @@ -2,7 +2,7 @@ id: 6582507654b3ed5712341382 title: Paso 29 challengeType: 20 -dashedName: step-29 +dashedName: step-30 --- # --description-- diff --git a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md index 7a485aef5e7..eb68e5a3e89 100644 --- a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md +++ b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md @@ -2,7 +2,7 @@ id: 658252f6b1526d57b103d48a title: Paso 30 challengeType: 20 -dashedName: step-30 +dashedName: step-31 --- # --description-- diff --git a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md index d032f832f39..a566b8e6751 100644 --- a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md +++ b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md @@ -2,7 +2,7 @@ id: 658254db6e12485a48130f57 title: Paso 31 challengeType: 20 -dashedName: step-31 +dashedName: step-32 --- # --description-- diff --git a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md index c04c59a722a..a9cb143d733 100644 --- a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md +++ b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md @@ -2,7 +2,7 @@ id: 658255d5f955175b270f251d title: Paso 32 challengeType: 20 -dashedName: step-32 +dashedName: step-33 --- # --description-- diff --git a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md index 5355623d70f..c6a369b2a84 100644 --- a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md +++ b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md @@ -2,7 +2,7 @@ id: 6582575b8089f85b8b92d7c8 title: Paso 33 challengeType: 20 -dashedName: step-33 +dashedName: step-34 --- # --description-- diff --git a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md index a0226a969c9..38297fd4f6d 100644 --- a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md +++ b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md @@ -2,7 +2,7 @@ id: 658258c0e5fbe85c14c060cf title: Paso 34 challengeType: 20 -dashedName: step-34 +dashedName: step-35 --- # --description-- diff --git a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md index e90b505ac4b..a36bbfca7d7 100644 --- a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md +++ b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md @@ -2,7 +2,7 @@ id: 65825a9520a0795c8afbef50 title: Paso 35 challengeType: 20 -dashedName: step-35 +dashedName: step-36 --- # --description-- diff --git a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md index 9d14ecf390c..08bf13ebc6e 100644 --- a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md +++ b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md @@ -2,7 +2,7 @@ id: 65825b758fe85a5cebabc8c5 title: Paso 36 challengeType: 20 -dashedName: step-36 +dashedName: step-37 --- # --description-- diff --git a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md index fae0081026f..a38a584af50 100644 --- a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md +++ b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md @@ -2,7 +2,7 @@ id: 65825cda2668995d5168e37c title: Paso 37 challengeType: 20 -dashedName: step-37 +dashedName: step-38 --- # --description-- diff --git a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md index a404df06974..5d0f415c1cb 100644 --- a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md +++ b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md @@ -2,7 +2,7 @@ id: 65825e96b5db5f5dee6bf57c title: Paso 38 challengeType: 20 -dashedName: step-38 +dashedName: step-39 --- # --description-- diff --git a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md index 5e2ee70237e..acfdea6c854 100644 --- a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md +++ b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md @@ -2,7 +2,7 @@ id: 6582601b2987045e8e7da994 title: Paso 39 challengeType: 20 -dashedName: step-39 +dashedName: step-40 --- # --description-- diff --git a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md index fdacce5a902..b1d1da892e6 100644 --- a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md +++ b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md @@ -2,7 +2,7 @@ id: 6582622cb6c11a5f4c5d79b4 title: Paso 40 challengeType: 20 -dashedName: step-40 +dashedName: step-41 --- # --description-- diff --git a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md index c9e7b7df3ba..09954161b79 100644 --- a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md +++ b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md @@ -2,7 +2,7 @@ id: 6582687859366a618424d84b title: Paso 41 challengeType: 20 -dashedName: step-41 +dashedName: step-42 --- # --description-- diff --git a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md index 92bbafd81d0..314c758b804 100644 --- a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md +++ b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md @@ -2,7 +2,7 @@ id: 65826a6e9d189a623141c726 title: Paso 42 challengeType: 20 -dashedName: step-42 +dashedName: step-43 --- # --description-- diff --git a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md index 75b4373ac3f..ebb514fdeae 100644 --- a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md +++ b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md @@ -2,7 +2,7 @@ id: 65826af5b226a5628aa154b1 title: Paso 43 challengeType: 20 -dashedName: step-43 +dashedName: step-44 --- # --description-- diff --git a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826befd75db5632bd73df6.md b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826befd75db5632bd73df6.md deleted file mode 100644 index 1eab4eaad61..00000000000 --- a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826befd75db5632bd73df6.md +++ /dev/null @@ -1,145 +0,0 @@ ---- -id: 65826befd75db5632bd73df6 -title: Paso 44 -challengeType: 20 -dashedName: step-44 ---- - -# --description-- - -You can use the `__name__` variable to determine if a Python script is being run as the main program or if it is being imported as a module (code written in another Python file). - -If the value of `__name__` is set to `'__main__'`, it implies that the current script is the main program, and not a module. - -As a final step, create an `if` statement to check if `__name__ == '__main__'`, and move the `main()` call inside this block. - -With that, the expense tracker project is complete! - -# --hints-- - -You should have `if __name__ == '__main__':` in your code. - -```js -assert.match(code,/^if\s+__name__\s*==\s*("|')__main__\1\s*:/m); -``` - -Your `main()` call should be inside the `if` statement. - -```js -assert.match(code, /^if\s+__name__\s*==\s*("|')__main__\1\s*:\s*main\s*\(\s*\)/m); -``` - -# --seed-- - -## --seed-contents-- - -```py -def add_expense(expenses, amount, category): - expenses.append({'amount': amount, 'category': category}) - -def print_expenses(expenses): - for expense in expenses: - print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - -def total_expenses(expenses): - return sum(map(lambda expense: expense['amount'], expenses)) - -def filter_expenses_by_category(expenses, category): - return filter(lambda expense: expense['category'] == category, expenses) - - -def main(): - expenses = [] - while True: - print('\nExpense Tracker') - print('1. Add an expense') - print('2. List all expenses') - print('3. Show total expenses') - print('4. Filter expenses by category') - print('5. Exit') - - choice = input('Enter your choice: ') - - if choice == '1': - amount = float(input('Enter amount: ')) - category = input('Enter category: ') - add_expense(expenses, amount, category) - - elif choice == '2': - print('\nAll Expenses:') - print_expenses(expenses) - - elif choice == '3': - print('\nTotal Expenses: ', total_expenses(expenses)) - - elif choice == '4': - category = input('Enter category to filter: ') - print(f'\nExpenses for {category}:') - expenses_from_category = filter_expenses_by_category(expenses, category) - print_expenses(expenses_from_category) - - elif choice == '5': - print('Exiting the program.') - break - ---fcc-editable-region-- -main() ---fcc-editable-region-- -``` - - -# --solutions-- - -```py -def add_expense(expenses, amount, category): - expenses.append({'amount': amount, 'category': category}) - -def print_expenses(expenses): - for expense in expenses: - print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - -def total_expenses(expenses): - return sum(map(lambda expense: expense['amount'], expenses)) - -def filter_expenses_by_category(expenses, category): - return filter(lambda expense: expense['category'] == category, expenses) - - -def main(): - expenses = [] - while True: - print('\nExpense Tracker') - print('1. Add an expense') - print('2. List all expenses') - print('3. Show total expenses') - print('4. Filter expenses by category') - print('5. Exit') - - choice = input('Enter your choice: ') - - if choice == '1': - amount = float(input('Enter amount: ')) - category = input('Enter category: ') - add_expense(expenses, amount, category) - - elif choice == '2': - print('\nAll Expenses:') - print_expenses(expenses) - - elif choice == '3': - print('\nTotal Expenses: ', total_expenses(expenses)) - - elif choice == '4': - category = input('Enter category to filter: ') - print(f'\nExpenses for {category}:') - expenses_from_category = filter_expenses_by_category(expenses, category) - print_expenses(expenses_from_category) - - elif choice == '5': - print('Exiting the program.') - break - -if __name__ == '__main__': - main() - -``` diff --git a/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/66314f2add0a8b57da5d6d91.md b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/66314f2add0a8b57da5d6d91.md new file mode 100644 index 00000000000..43669da4b07 --- /dev/null +++ b/curriculum/challenges/espanol/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/66314f2add0a8b57da5d6d91.md @@ -0,0 +1,43 @@ +--- +id: 66314f2add0a8b57da5d6d91 +title: Step 14 +challengeType: 20 +dashedName: step-14 +--- + +# --description-- + +You should see something like `` printed on the console, which is the string representation of the map object returned by `map()`. + +To obtain a readable output you need to turn the map object into a list. Do it by passing the `map()` call as the argument to the `list()` function. + +# --hints-- + +You should pass the `map()` call as the argument to the `list()` function. + +```js +({ test: () => assert(runPython(`_Node(_code).has_call("print(list(map(test, [2,3,5,8])))")`)) }) +``` + +# --seed-- + +## --seed-contents-- + +```py +def add_expense(expenses, amount, category): + expenses.append({'amount': amount, 'category': category}) + +def print_expenses(expenses): + for expense in expenses: + print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') + +def total_expenses(expenses): + pass + +--fcc-editable-region-- +test = lambda x: x * 2 +print(map(test, [2, 3, 5, 8])) +--fcc-editable-region-- + +expenses = [] +``` diff --git a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md index 21988a1dbc0..11b69e423a1 100644 --- a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md +++ b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md @@ -2,7 +2,7 @@ id: 658238f7604f154ea9a23e1e title: Schritt 14 challengeType: 20 -dashedName: step-14 +dashedName: step-15 --- # --description-- diff --git a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md index 3893ade79b0..305846025f2 100644 --- a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md +++ b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md @@ -2,7 +2,7 @@ id: 65823b0167fd894f4a7ea60a title: Schritt 15 challengeType: 20 -dashedName: step-15 +dashedName: step-16 --- # --description-- diff --git a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md index b0851b9e432..931f0fabe5d 100644 --- a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md +++ b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md @@ -2,7 +2,7 @@ id: 65823bbbdb4eaa4f9d20a0fb title: Schritt 16 challengeType: 20 -dashedName: step-16 +dashedName: step-17 --- # --description-- diff --git a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md index 2b2ae04abaf..6a0c68b96b4 100644 --- a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md +++ b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md @@ -2,7 +2,7 @@ id: 65823cfc74aa564ffc460489 title: Schritt 17 challengeType: 20 -dashedName: step-17 +dashedName: step-18 --- # --description-- diff --git a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md index 6c80ef6e4ee..0aa3c46e4d2 100644 --- a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md +++ b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md @@ -2,7 +2,7 @@ id: 65823dde36392f505a39f7c7 title: Schritt 18 challengeType: 20 -dashedName: step-18 +dashedName: step-19 --- # --description-- diff --git a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md index a7a0dabb843..344b27a2bf8 100644 --- a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md +++ b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md @@ -2,7 +2,7 @@ id: 65823e87c9741750a22085a7 title: Schritt 19 challengeType: 20 -dashedName: step-19 +dashedName: step-20 --- # --description-- diff --git a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md index 74d529af0d5..90062492a86 100644 --- a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md +++ b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md @@ -2,7 +2,7 @@ id: 65823ff0d4b991510fade1a8 title: Schritt 20 challengeType: 20 -dashedName: step-20 +dashedName: step-21 --- # --description-- diff --git a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md index 00eecc0bd6b..d820771f21f 100644 --- a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md +++ b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md @@ -2,7 +2,7 @@ id: 65824111a09164518320088d title: Schritt 21 challengeType: 20 -dashedName: step-21 +dashedName: step-22 --- # --description-- diff --git a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md index 75e8e49c29e..2aec8800f96 100644 --- a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md +++ b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md @@ -2,7 +2,7 @@ id: 658244fdf4b0265334711664 title: Schritt 22 challengeType: 20 -dashedName: step-22 +dashedName: step-23 --- # --description-- diff --git a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md index 27f5ca8759c..650c9074b9e 100644 --- a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md +++ b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md @@ -2,7 +2,7 @@ id: 65824561f3478e5371a33ae5 title: Schritt 23 challengeType: 20 -dashedName: step-23 +dashedName: step-24 --- # --description-- diff --git a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md index da5f6d91adc..55b60b45cb7 100644 --- a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md +++ b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md @@ -2,7 +2,7 @@ id: 658246c28575d653d1f89b59 title: Schritt 24 challengeType: 20 -dashedName: step-24 +dashedName: step-25 --- # --description-- diff --git a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md index 0f447b5eb4d..4085c905dd8 100644 --- a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md +++ b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md @@ -2,7 +2,7 @@ id: 65824872894f59546e3084e2 title: Schritt 25 challengeType: 20 -dashedName: step-25 +dashedName: step-26 --- # --description-- diff --git a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md index 29575b7375a..22d112ba0aa 100644 --- a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md +++ b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md @@ -2,7 +2,7 @@ id: 65824a1b16631c54fa524154 title: Step 26 challengeType: 20 -dashedName: step-26 +dashedName: step-27 --- # --description-- diff --git a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md index d6b34082931..dc122615122 100644 --- a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md +++ b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md @@ -2,7 +2,7 @@ id: 65824c7b4e2da85597693dcf title: Schritt 27 challengeType: 20 -dashedName: step-27 +dashedName: step-28 --- # --description-- diff --git a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md index 24c27b6240f..f262854dfc7 100644 --- a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md +++ b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md @@ -2,7 +2,7 @@ id: 65824dfdb6815d563b2d3256 title: Schritt 28 challengeType: 20 -dashedName: step-28 +dashedName: step-29 --- # --description-- diff --git a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md index 057a242e95d..12a1c76e82c 100644 --- a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md +++ b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md @@ -2,7 +2,7 @@ id: 6582507654b3ed5712341382 title: Schritt 29 challengeType: 20 -dashedName: step-29 +dashedName: step-30 --- # --description-- diff --git a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md index 4921c9fec96..0868eefb8e9 100644 --- a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md +++ b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md @@ -2,7 +2,7 @@ id: 658252f6b1526d57b103d48a title: Schritt 30 challengeType: 20 -dashedName: step-30 +dashedName: step-31 --- # --description-- diff --git a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md index 037282c5bb1..ea8a4918d6b 100644 --- a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md +++ b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md @@ -2,7 +2,7 @@ id: 658254db6e12485a48130f57 title: Schritt 31 challengeType: 20 -dashedName: step-31 +dashedName: step-32 --- # --description-- diff --git a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md index 1e2992b0d9c..29678f71868 100644 --- a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md +++ b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md @@ -2,7 +2,7 @@ id: 658255d5f955175b270f251d title: Schritt 32 challengeType: 20 -dashedName: step-32 +dashedName: step-33 --- # --description-- diff --git a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md index 5e5ddd95cb3..ca876a0c861 100644 --- a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md +++ b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md @@ -2,7 +2,7 @@ id: 6582575b8089f85b8b92d7c8 title: Schritt 33 challengeType: 20 -dashedName: step-33 +dashedName: step-34 --- # --description-- diff --git a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md index f812abc230b..c0f179510b8 100644 --- a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md +++ b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md @@ -2,7 +2,7 @@ id: 658258c0e5fbe85c14c060cf title: Schritt 34 challengeType: 20 -dashedName: step-34 +dashedName: step-35 --- # --description-- diff --git a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md index 87c11614b10..8edabb9c3c1 100644 --- a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md +++ b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md @@ -2,7 +2,7 @@ id: 65825a9520a0795c8afbef50 title: Schritt 35 challengeType: 20 -dashedName: step-35 +dashedName: step-36 --- # --description-- diff --git a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md index 66425d6b4d3..69c108f018b 100644 --- a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md +++ b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md @@ -2,7 +2,7 @@ id: 65825b758fe85a5cebabc8c5 title: Schritt 36 challengeType: 20 -dashedName: step-36 +dashedName: step-37 --- # --description-- diff --git a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md index 95a5c5c686f..86169026ab8 100644 --- a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md +++ b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md @@ -2,7 +2,7 @@ id: 65825cda2668995d5168e37c title: Schritt 37 challengeType: 20 -dashedName: step-37 +dashedName: step-38 --- # --description-- diff --git a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md index fa35e30e240..83d18cb3364 100644 --- a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md +++ b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md @@ -2,7 +2,7 @@ id: 65825e96b5db5f5dee6bf57c title: Schritt 38 challengeType: 20 -dashedName: step-38 +dashedName: step-39 --- # --description-- diff --git a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md index 71b138235c3..d2d39ae830f 100644 --- a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md +++ b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md @@ -2,7 +2,7 @@ id: 6582601b2987045e8e7da994 title: Schritt 39 challengeType: 20 -dashedName: step-39 +dashedName: step-40 --- # --description-- diff --git a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md index 0a7c53e714b..1a82b9eb539 100644 --- a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md +++ b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md @@ -2,7 +2,7 @@ id: 6582622cb6c11a5f4c5d79b4 title: Schritt 40 challengeType: 20 -dashedName: step-40 +dashedName: step-41 --- # --description-- diff --git a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md index fa717dded06..3a29c02d1de 100644 --- a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md +++ b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md @@ -2,7 +2,7 @@ id: 6582687859366a618424d84b title: Schritt 41 challengeType: 20 -dashedName: step-41 +dashedName: step-42 --- # --description-- diff --git a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md index 3d93b087b34..69e523d58c5 100644 --- a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md +++ b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md @@ -2,7 +2,7 @@ id: 65826a6e9d189a623141c726 title: Schritt 42 challengeType: 20 -dashedName: step-42 +dashedName: step-43 --- # --description-- diff --git a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md index d0237456db2..186f547c285 100644 --- a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md +++ b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md @@ -2,7 +2,7 @@ id: 65826af5b226a5628aa154b1 title: Schritt 43 challengeType: 20 -dashedName: step-43 +dashedName: step-44 --- # --description-- diff --git a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826befd75db5632bd73df6.md b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826befd75db5632bd73df6.md deleted file mode 100644 index c04bea4495d..00000000000 --- a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826befd75db5632bd73df6.md +++ /dev/null @@ -1,145 +0,0 @@ ---- -id: 65826befd75db5632bd73df6 -title: Schritt 44 -challengeType: 20 -dashedName: step-44 ---- - -# --description-- - -You can use the `__name__` variable to determine if a Python script is being run as the main program or if it is being imported as a module (code written in another Python file). - -If the value of `__name__` is set to `'__main__'`, it implies that the current script is the main program, and not a module. - -As a final step, create an `if` statement to check if `__name__ == '__main__'`, and move the `main()` call inside this block. - -With that, the expense tracker project is complete! - -# --hints-- - -You should have `if __name__ == '__main__':` in your code. - -```js -assert.match(code,/^if\s+__name__\s*==\s*("|')__main__\1\s*:/m); -``` - -Your `main()` call should be inside the `if` statement. - -```js -assert.match(code, /^if\s+__name__\s*==\s*("|')__main__\1\s*:\s*main\s*\(\s*\)/m); -``` - -# --seed-- - -## --seed-contents-- - -```py -def add_expense(expenses, amount, category): - expenses.append({'amount': amount, 'category': category}) - -def print_expenses(expenses): - for expense in expenses: - print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - -def total_expenses(expenses): - return sum(map(lambda expense: expense['amount'], expenses)) - -def filter_expenses_by_category(expenses, category): - return filter(lambda expense: expense['category'] == category, expenses) - - -def main(): - expenses = [] - while True: - print('\nExpense Tracker') - print('1. Add an expense') - print('2. List all expenses') - print('3. Show total expenses') - print('4. Filter expenses by category') - print('5. Exit') - - choice = input('Enter your choice: ') - - if choice == '1': - amount = float(input('Enter amount: ')) - category = input('Enter category: ') - add_expense(expenses, amount, category) - - elif choice == '2': - print('\nAll Expenses:') - print_expenses(expenses) - - elif choice == '3': - print('\nTotal Expenses: ', total_expenses(expenses)) - - elif choice == '4': - category = input('Enter category to filter: ') - print(f'\nExpenses for {category}:') - expenses_from_category = filter_expenses_by_category(expenses, category) - print_expenses(expenses_from_category) - - elif choice == '5': - print('Exiting the program.') - break - ---fcc-editable-region-- -main() ---fcc-editable-region-- -``` - - -# --solutions-- - -```py -def add_expense(expenses, amount, category): - expenses.append({'amount': amount, 'category': category}) - -def print_expenses(expenses): - for expense in expenses: - print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - -def total_expenses(expenses): - return sum(map(lambda expense: expense['amount'], expenses)) - -def filter_expenses_by_category(expenses, category): - return filter(lambda expense: expense['category'] == category, expenses) - - -def main(): - expenses = [] - while True: - print('\nExpense Tracker') - print('1. Add an expense') - print('2. List all expenses') - print('3. Show total expenses') - print('4. Filter expenses by category') - print('5. Exit') - - choice = input('Enter your choice: ') - - if choice == '1': - amount = float(input('Enter amount: ')) - category = input('Enter category: ') - add_expense(expenses, amount, category) - - elif choice == '2': - print('\nAll Expenses:') - print_expenses(expenses) - - elif choice == '3': - print('\nTotal Expenses: ', total_expenses(expenses)) - - elif choice == '4': - category = input('Enter category to filter: ') - print(f'\nExpenses for {category}:') - expenses_from_category = filter_expenses_by_category(expenses, category) - print_expenses(expenses_from_category) - - elif choice == '5': - print('Exiting the program.') - break - -if __name__ == '__main__': - main() - -``` diff --git a/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/66314f2add0a8b57da5d6d91.md b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/66314f2add0a8b57da5d6d91.md new file mode 100644 index 00000000000..43669da4b07 --- /dev/null +++ b/curriculum/challenges/german/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/66314f2add0a8b57da5d6d91.md @@ -0,0 +1,43 @@ +--- +id: 66314f2add0a8b57da5d6d91 +title: Step 14 +challengeType: 20 +dashedName: step-14 +--- + +# --description-- + +You should see something like `` printed on the console, which is the string representation of the map object returned by `map()`. + +To obtain a readable output you need to turn the map object into a list. Do it by passing the `map()` call as the argument to the `list()` function. + +# --hints-- + +You should pass the `map()` call as the argument to the `list()` function. + +```js +({ test: () => assert(runPython(`_Node(_code).has_call("print(list(map(test, [2,3,5,8])))")`)) }) +``` + +# --seed-- + +## --seed-contents-- + +```py +def add_expense(expenses, amount, category): + expenses.append({'amount': amount, 'category': category}) + +def print_expenses(expenses): + for expense in expenses: + print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') + +def total_expenses(expenses): + pass + +--fcc-editable-region-- +test = lambda x: x * 2 +print(map(test, [2, 3, 5, 8])) +--fcc-editable-region-- + +expenses = [] +``` diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658212ba98182f3e855e85f9.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658212ba98182f3e855e85f9.md index 90725056be2..51f05e69ed6 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658212ba98182f3e855e85f9.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658212ba98182f3e855e85f9.md @@ -13,7 +13,7 @@ Start by defining a function named `add_expense` that takes three parameters: `e # --hints-- -You should declare a function named `add_expense`. +You should use the `def` keyword to declare a function named `add_expense`. ```js ({ test: () => assert(runPython(` diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65821c1c40ccac44adf38e6b.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65821c1c40ccac44adf38e6b.md index 24036657d8b..f2392be1fac 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65821c1c40ccac44adf38e6b.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65821c1c40ccac44adf38e6b.md @@ -1,19 +1,19 @@ --- id: 65821c1c40ccac44adf38e6b -title: Passo 2 +title: Step 2 challengeType: 20 dashedName: step-2 --- # --description-- -A list in Python is a built-in data type that allows you to store many items in a single data structure. In Python, you create a list by putting items inside square brackets `[]`, with each item separated from the following one by a comma. +A list in Python is a built-in data type that allows you to store many items in a single data structure. In Python, you create a list by putting items inside square brackets (`[]`), with each item separated from the following one by a comma. ```py numbers = [1, 2, 3, 4] ``` -Create an empty list named `expenses`. You will use it to store each of your expenses. +Use a pair of square brackets to create an empty list named `expenses`. You will use it to store each of your expenses. # --hints-- @@ -36,7 +36,7 @@ You should assign an empty list to the `expenses` variable. ```py def add_expense(expenses, amount, category): pass - + --fcc-editable-region-- --fcc-editable-region-- diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65821fcc010c3245718f2a06.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65821fcc010c3245718f2a06.md index 0c83f09ee12..7f5af99e0a8 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65821fcc010c3245718f2a06.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65821fcc010c3245718f2a06.md @@ -7,21 +7,29 @@ dashedName: step-3 # --description-- -The `expenses` parameter of your `add_expense` function will be a list of expenses. You want to be able to add items at the end of your list. For that you can use the `.append()` list method: +The `expenses` parameter of your `add_expense` function will be a list of expenses. You want to be able to add items at the end of your list. For that you'll use the `.append()` list method: ```py my_list = [2, 4, 7] my_list.append(3) ``` -In the example above, after appending `3`, `my_list` would be `[2, 4, 7, 3]`. Replace `pass` with a call to the `.append()` method on the `expenses` list. Don't pass any arguments to `.append()` for now. +In the example above, after appending `3`, `my_list` would be `[2, 4, 7, 3]`. + +Replace `pass` with a call to the `.append()` method on the `expenses` list. Don't pass any arguments to `.append()` for now. # --hints-- You should have `expenses.append()` in your function. ```js -assert.match(code, /^\s+expenses\.append\s*\(\s*\)/m) +({ test: () => assert(runPython(`_Node(_code).find_function("add_expense").has_stmt("expenses.append()")`)) }) +``` + +You should not have `pass` in your function. + +```js +({ test: () => assert.isFalse(runPython(`_Node(_code).find_function("add_expense").has_pass()`)) }) ``` # --seed-- diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822308ded1ba4632f66aa3.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822308ded1ba4632f66aa3.md index 5c850342519..e89afc026b6 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822308ded1ba4632f66aa3.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822308ded1ba4632f66aa3.md @@ -7,7 +7,7 @@ dashedName: step-4 # --description-- -A dictionary is another built-in data type in Python. A dictionary is a collection of data in the form of *key*-*value* pairs. Dictionaries are defined with curly braces `{}` and they contain key-value pairs separated by commas. Each key is followed by a colon `:` and the value: +A dictionary is another built-in data type in Python. A dictionary is a collection of data in the form of *key*-*value* pairs. Dictionaries are defined with curly braces (`{}`) and they contain key-value pairs separated by commas. Each key is followed by a colon (`:`) and the value: ```py {'amount': 50.0, 'category': 'Food'} @@ -19,10 +19,20 @@ Create a dictionary with a key `'amount'` and value of the `amount` parameter an # --hints-- -You should have `expenses.append({'amount': amount})` in your function. +You should pass a dictionary as the argument to the `.append()` method. ```js -assert.match(code, /^\s+expenses\.append\s*\(\s*\{\s*("|')amount\1\s*:\s*amount\s*\}\s*\)/m) +({ test: () => assert(runPython(` +import ast +node = _Node(_code).find_function("add_expense").find_calls("append")[0].find_call_args() +len(node) == 1 and isinstance(node[0].tree, ast.Dict) +`)) }) +``` + +You should pass `{'amount': amount}` as the argument to the `.append()` method. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("add_expense").has_stmt("expenses.append({'amount': amount})")`)) }) ``` # --seed-- diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658225d560369446ece5518b.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658225d560369446ece5518b.md index 510a44b67ab..721a796db68 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658225d560369446ece5518b.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658225d560369446ece5518b.md @@ -11,10 +11,20 @@ Add another key-value pair to the dictionary you are appending to the `expense` # --hints-- -You should have `expenses.append({'amount': amount, 'category': category})` in your code. +You should add a second key-value pair to the dictionary you are passing as the argument to the `.append()` method. ```js -assert.match(code, /^\s+expenses\.append\s*\(\s*\{\s*("|')amount\1\s*:\s*amount\s*,\s*("|')category\2\s*:\s*category\s*\}\s*\)/m) +({ test: () => assert(runPython(` +import ast +node = _Node(_code).find_function("add_expense").find_calls("append")[0].find_call_args() +len(node) == 1 and isinstance(node[0].tree, ast.Dict) and len(node[0].tree.keys) == 2 +`)) }) +``` + +You should pass `{'amount': amount, 'category': category}` as the argument to the `.append()` method. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("add_expense").has_stmt("expenses.append({'amount': amount, 'category': category})")`)) }) ``` # --seed-- diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582267ef39f5047411c1743.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582267ef39f5047411c1743.md index 7695824ec3b..75485fdd124 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582267ef39f5047411c1743.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582267ef39f5047411c1743.md @@ -7,7 +7,7 @@ dashedName: step-6 # --description-- -Start by defining a function named `print_expenses` that takes one parameter `expenses`. This function will later be used to display each expense in your list. +Next, define a function named `print_expenses` that takes one parameter `expenses`. This function will later be used to display each expense in your list. Fill the body of your new function with a `pass` statement. @@ -41,7 +41,7 @@ Your `print_expenses` function should take a single parameter `expenses`. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + --fcc-editable-region-- --fcc-editable-region-- diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822773f4c60a479ec89f66.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822773f4c60a479ec89f66.md index 9b084b00236..46a26e45ab9 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822773f4c60a479ec89f66.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822773f4c60a479ec89f66.md @@ -11,10 +11,22 @@ Inside the `print_expenses` function, create a `for` loop that iterates over eac # --hints-- -You should have `for expense in expenses:` in your `print_expenses` function. Remember to use `pass` within the loop body. +You should create a `for` loop that iterates over `expenses` in your `print_expenses` function. Remember to use `pass` within the loop body. ```js -({ test: () => assert.match(code, /for\s+expense\s+in\s+expenses\s*:/ ) }) +({ test: () => assert(runPython(`_Node(_code).find_function("print_expenses").find_for_loops()[0].find_for_iter().is_equivalent("expenses")`)) }) +``` + +You should use `expense` as the loop variable. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("print_expenses").find_for_loops()[0].find_for_vars().is_equivalent("expense")`)) }) +``` + +You should have `pass` only inside your loop body. + +```js +({ test: () => assert.isFalse(runPython(`_Node(_code).find_function("print_expenses").has_pass()`)) }) ``` # --seed-- @@ -24,7 +36,7 @@ You should have `for expense in expenses:` in your `print_expenses` function. Re ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + --fcc-editable-region-- def print_expenses(expenses): pass diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822934c8a0454803e3ef12.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822934c8a0454803e3ef12.md index 84a69b3ede3..d8e1f7d2e9f 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822934c8a0454803e3ef12.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822934c8a0454803e3ef12.md @@ -9,14 +9,20 @@ dashedName: step-8 Next, you are going to display the details for each expense. -Inside the `for` loop, replace `pass` with a `print()` call and pass it the following f-string: `f'Amount: {expense}, Category: {expense}'`. Leave the placeholders empty for now. +Inside the `for` loop, replace `pass` with a `print()` call and pass it the following f-string: `f'Amount: {expense}, Category: {expense}'`. # --hints-- -You should have `print(f'Amount: {expense}, Category: {expense}')` in your `for` loop. +You should print `f'Amount: {expense}, Category: {expense}'` in your `for` loop. ```js -({ test: () => assert.match(code, /^\s+print\s*\(\s*f("|')Amount: \{\s*expense\s*\}, Category: \{\s*expense\s*\}\1\s*\)/m) }) +({ test: () => assert(runPython(`_Node(_code).find_function("print_expenses").find_for_loops()[0].has_call("print(f'Amount: {expense}, Category: {expense}')")`)) }) +``` + +You should not have `pass` inside your loop body. + +```js +({ test: () => assert.isFalse(runPython(`_Node(_code).find_function("print_expenses").find_for_loops()[0].find_bodies()[0].has_pass()`)) }) ``` # --seed-- @@ -26,7 +32,7 @@ You should have `print(f'Amount: {expense}, Category: {expense}')` in your `for` ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + --fcc-editable-region-- def print_expenses(expenses): for expense in expenses: diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822bd82d708c4895080c35.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822bd82d708c4895080c35.md index 7f9f383b8cb..3fa3fb568b9 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822bd82d708c4895080c35.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822bd82d708c4895080c35.md @@ -7,7 +7,12 @@ dashedName: step-9 # --description-- -You can access values in a dictionary through its keys. You need to use the bracket notation and include the key between the square brackets: +In Python, an important thing to know is that the same type of quote used to define a string cannot be used inside it. For example, the string `'I'm a string!'` is not valid. To use the single quote inside that string you should either: + +- Escape the quote by prepending a backlash to it: `'I\'m a string!'` +- Or use double quotes to define the string: `"I'm a string!"` (preferred). + +You can access values in a dictionary through its keys. You need to use bracket notation and include the key between the square brackets: ```py my_dict = {'amount': 50.0, 'category': 'Food'} @@ -31,7 +36,7 @@ You should pass `f'Amount: {expense["amount"]}, Category: {expense["category"]}' ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + --fcc-editable-region-- def print_expenses(expenses): for expense in expenses: diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823040bdb32949d4c1a96f.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823040bdb32949d4c1a96f.md index c8a9d89cd40..ab3e2f9fc07 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823040bdb32949d4c1a96f.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823040bdb32949d4c1a96f.md @@ -1,13 +1,15 @@ --- id: 65823040bdb32949d4c1a96f -title: Passo 10 +title: Step 10 challengeType: 20 dashedName: step-10 --- # --description-- -You will need a function to calculate the total amount of expenses. Define a function named `total_expenses` that takes one parameter `expenses`. Fill the function body with a `pass` statement for now. +You will need a function to calculate the total amount of expenses. + +Define a function named `total_expenses` that takes one parameter `expenses`. Fill the function body with a `pass` statement for now. # --hints-- @@ -21,7 +23,7 @@ You should define a function named `total_expenses`. }) ``` -Your`total_expenses` function should take a single `expenses` parameter. +Your `total_expenses` function should take a single `expenses` parameter. ```js ({ test: () => assert(runPython(` @@ -39,7 +41,7 @@ Your`total_expenses` function should take a single `expenses` parameter. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582324b5d37fe4b622bc3c0.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582324b5d37fe4b622bc3c0.md index 43490a8b458..6e9189ed3f0 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582324b5d37fe4b622bc3c0.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582324b5d37fe4b622bc3c0.md @@ -13,14 +13,22 @@ Lambda functions are brief, anonymous functions in Python, ideal for simple, one lambda x: expr ``` -In the example above, `x` is a parameter to be used in the expression `expr`. Create a `test` variable and assign it a lambda function that takes an `x` parameter and returns `x * 2`. +In the example above, `x` represents a parameter to be used in the expression `expr`, and it acts just like any parameter in a traditional function. `expr` is the expression that gets evaluated and returned when the lambda function is called. + +Create a variable named `test` and assign it a lambda function that takes an `x` parameter and returns `x * 2`. # --hints-- -You should have `test = lambda x: x * 2` in your code. +You should declare a variable named `test`. ```js -({ test: () => assert.match(code,/^test\s*=\s*lambda\s+x\s*:\s*x\s*\*\s*2/m)}) +({ test: () => assert(runPython(`_Node(_code).has_variable("test")`))}) +``` + +You should assign `lambda x: x * 2` to your `test` variable. + +```js +({ test: () => assert(runPython(`_Node(_code).find_variable("test").is_equivalent("test = lambda x: x * 2")`))}) ``` # --seed-- @@ -30,14 +38,14 @@ You should have `test = lambda x: x * 2` in your code. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') def total_expenses(expenses): pass - + --fcc-editable-region-- --fcc-editable-region-- diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582352cbdbcde4d0c4f7b0b.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582352cbdbcde4d0c4f7b0b.md index ff500947680..60685d4ceba 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582352cbdbcde4d0c4f7b0b.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582352cbdbcde4d0c4f7b0b.md @@ -26,14 +26,14 @@ You should have `print(test(3))` in your code. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') def total_expenses(expenses): pass - + --fcc-editable-region-- test = lambda x: x * 2 diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823634a308cb4d6bcc5fa6.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823634a308cb4d6bcc5fa6.md index f651f054e14..59eb3e3c77b 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823634a308cb4d6bcc5fa6.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823634a308cb4d6bcc5fa6.md @@ -13,9 +13,11 @@ Lambda functions can be valuably combined with the `map()` function, which execu map(lambda x: x * 2, [1, 2, 3]) ``` +The function to execute is passed as the first argument, and the iterable is passed as the second argument. + The result of the example above would be `[2, 4, 6]`, where each item in the list passed to `map()` has been doubled by the action of the lambda function. -Modify your `print()` call to print the result of calling `map()` with `test` as the first argument, and `[2, 3, 5, 8]` as the second argument. +Modify your `print()` call to print the result of calling `map()` with `test` as the first argument, and `[2, 3, 5, 8]` as the second argument. You won't be able to see a readable output yet. # --hints-- @@ -32,14 +34,14 @@ You should have `print(map(test, [2, 3, 5, 8]))` in your code. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') def total_expenses(expenses): pass - + --fcc-editable-region-- test = lambda x: x * 2 print(test(3)) diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md index 3937f502dcd..d9226ae6d34 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md @@ -1,15 +1,15 @@ --- id: 658238f7604f154ea9a23e1e -title: Step 14 +title: Step 15 challengeType: 20 -dashedName: step-14 +dashedName: step-15 --- # --description-- The `sum()` function returns the sum of the items in the iterable which is passed as its argument. You are going to use `sum()` together with `map()` and `lambda` functions to get the total amount of expenses. -For now, make a little test and modify your current `print()` call by passing `sum(map(test, [2, 3, 5, 8]))` as the argument. +For now, make a little test and modify your current `print()` call replacing the `list()` call with a call to the `sum()` function passing it the current `map()` call as the argument. # --hints-- @@ -26,17 +26,17 @@ You should print `sum(map(test, [2, 3, 5, 8]))`. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') def total_expenses(expenses): pass - + --fcc-editable-region-- test = lambda x: x * 2 -print(map(test, [2, 3, 5, 8])) +print(list(map(test, [2,3,5,8]))) --fcc-editable-region-- expenses = [] diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md index e7f13761f99..c7358d25594 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md @@ -1,28 +1,22 @@ --- id: 65823b0167fd894f4a7ea60a -title: Passo 15 +title: Step 16 challengeType: 20 -dashedName: step-15 +dashedName: step-16 --- # --description-- -Next, you are going to implement the same logic to the `total_expenses` function. +Next, you are going to implement the same logic within the `total_expenses` function. For now, delete both the `test` function and the `print()` call. # --hints-- -You should delete your `test` variable. +You should delete your `test` variable and the related `print()` call. ```js -({ test: () => assert.notMatch(code, /test\s*=/) }) -``` - -You should delete your `print(sum(map(test, [2, 3, 5, 8])))` call. - -```js -({ test: () => assert.notMatch(code, /print\s*\(\s*sum/) }) +({ test: () => assert.isFalse(runPython(`_Node(_code).has_variable("test")`)) }) ``` # --seed-- @@ -32,14 +26,14 @@ You should delete your `print(sum(map(test, [2, 3, 5, 8])))` call. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') def total_expenses(expenses): pass - + --fcc-editable-region-- test = lambda x: x * 2 print(sum(map(test, [2, 3, 5, 8]))) diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md index 1fafe039961..b056b0bb531 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md @@ -1,27 +1,28 @@ --- id: 65823bbbdb4eaa4f9d20a0fb -title: Step 16 +title: Step 17 challengeType: 20 -dashedName: step-16 +dashedName: step-17 --- # --description-- -Within your `total_expenses` function, replace `pass` with a `lambda` function. Use `expense` as the parameter and return the value of the `'amount'` key in the `expense` dictionary. +In the `total_expenses` function, you'll now integrate a lambda function. Replace `pass` with a lambda function that has `expense` as its parameter. + +`expense` is expected to be a dictionary, and your lambda function should return the value of the `'amount'` key in the `expense` dictionary. # --hints-- -You should have `lambda expense: expense['amount']` in your `total_expenses` function. +You should create a `lambda` function that uses the parameter `expense` and returns `expense['amount']` in your `total_expenses` function. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "total_expenses"); - const {function_body} = foo; - assert(function_body.match(/^\s+lambda\s+expense\s*:\s*expense\s*\[\s*("|')amount\1\s*\]/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("total_expenses").has_stmt("lambda expense: expense['amount']")`)) }) +``` + +You should not have `pass` in your `total_expenses` function. + +```js +({ test: () => assert.isFalse(runPython(`_Node(_code).find_function("total_expenses").has_pass()`)) }) ``` # --seed-- @@ -31,11 +32,11 @@ You should have `lambda expense: expense['amount']` in your `total_expenses` fun ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + --fcc-editable-region-- def total_expenses(expenses): pass diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md index 6696f68dee3..9c4390b4669 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md @@ -1,8 +1,8 @@ --- id: 65823cfc74aa564ffc460489 -title: Passaggio 17 +title: Step 18 challengeType: 20 -dashedName: step-17 +dashedName: step-18 --- # --description-- @@ -11,17 +11,22 @@ Now, call `map()` passing your `lambda` function as the first argument and the ` # --hints-- -You should have `map(lambda expense: expense['amount'], expenses)` in your code. +You should call the `map()` function inside the `total_expenses` function. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "total_expenses"); - const {function_body} = foo; - assert(function_body.match(/^\s+map\s*\(\s*lambda\s+expense\s*:\s*expense\s*\[\s*("|')amount\1\s*\]\s*,\s*expenses\s*\)/m)); - } -}) +({ test: () => assert(runPython(`len(_Node(_code).find_function("total_expenses").find_calls("map")) == 1`)) }) +``` + +You should pass your `lambda` function as the first argument to the `map()` call. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("total_expenses").find_calls("map")[0].find_call_args()[0].is_equivalent("lambda expense: expense['amount']")`)) }) +``` + +You should pass the `expenses` list as the second argument to the `map()` call. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("total_expenses").find_calls("map")[0].find_call_args()[1].is_equivalent("expenses")`)) }) ``` # --seed-- @@ -31,11 +36,11 @@ You should have `map(lambda expense: expense['amount'], expenses)` in your code. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + --fcc-editable-region-- def total_expenses(expenses): lambda expense: expense['amount'] diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md index e19a6ff8af6..9ff07605fac 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md @@ -1,8 +1,8 @@ --- id: 65823dde36392f505a39f7c7 -title: Step 18 +title: Step 19 challengeType: 20 -dashedName: step-18 +dashedName: step-19 --- # --description-- @@ -11,17 +11,10 @@ Finally, pass your `map()` call to the `sum()` function to obtain the total expe # --hints-- -You should return `sum(map(lambda expense: expense['amount'], expenses))` from your `total_expenses` function. +You should call the `sum()` function passing it your current `map()` call as the argument and return the result from your `total_expenses` function. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "total_expenses"); - const {function_body} = foo; - assert(function_body.match(/^\s+return\s+sum\s*\(\s*map\s*\(\s*lambda\s+expense\s*:\s*expense\s*\[\s*("|')amount\1\s*\]\s*,\s*expenses\s*\)\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("total_expenses").has_return("sum(map(lambda expense: expense['amount'], expenses))")`)) }) ``` # --seed-- @@ -31,11 +24,11 @@ You should return `sum(map(lambda expense: expense['amount'], expenses))` from y ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + --fcc-editable-region-- def total_expenses(expenses): map(lambda expense: expense['amount'], expenses) diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md index 82dc3090fd8..da444c85097 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md @@ -1,8 +1,8 @@ --- id: 65823e87c9741750a22085a7 -title: Passo 19 +title: Step 20 challengeType: 20 -dashedName: step-19 +dashedName: step-20 --- # --description-- @@ -39,14 +39,14 @@ Your `filter_expenses_by_category` function should take `expenses` and `category ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + --fcc-editable-region-- --fcc-editable-region-- diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md index 758894d8784..92b7c92c01d 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md @@ -1,27 +1,26 @@ --- id: 65823ff0d4b991510fade1a8 -title: Step 20 +title: Step 21 challengeType: 20 -dashedName: step-20 +dashedName: step-21 --- # --description-- -Within the `filter_expenses_by_category` function, replace `pass` with a `lambda` function. Use `expense` as the parameter and return the comparison between the value of the `'category'` key of the `expense` dictionary and `category`. +Within the `filter_expenses_by_category` function, replace `pass` with a `lambda` function. Use `expense` as the parameter and return the comparison between the value of the `'category'` key of the `expense` dictionary and `category` using the equality operator. # --hints-- -You should have `lambda expense: expense['category'] == category` inside the `filter_expenses_by_category` function. +You should create a `lambda` function that uses a parameter named `expense` and returns the expression `expense['category'] == category` inside the `filter_expenses_by_category` function. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "filter_expenses_by_category"); - const {function_body} = foo; - assert(function_body.match(/^\s+lambda\s+expense\s*:\s*expense\s*\[\s*("|')category\1\s*\]\s*==\s*category/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("filter_expenses_by_category").has_stmt("lambda expense: expense['category'] == category")`)) }) +``` + +You should not have `pass` inside the `filter_expenses_by_category` function. + +```js +({ test: () => assert.isFalse(runPython(`_Node(_code).find_function("filter_expenses_by_category").has_pass()`)) }) ``` # --seed-- @@ -31,14 +30,14 @@ You should have `lambda expense: expense['category'] == category` inside the `fi ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + --fcc-editable-region-- def filter_expenses_by_category(expenses, category): pass diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md index c8a504c95b7..fe47ee9f3f2 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md @@ -1,35 +1,42 @@ --- id: 65824111a09164518320088d -title: Step 21 +title: Step 22 challengeType: 20 -dashedName: step-21 +dashedName: step-22 --- # --description-- -The `filter()` function allows you to select items from an iterable, such as a list, based on the output of a function: +The `filter()` function allows you to select items from an iterable, such as a list, based on the output of a function: ```py filter(my_function, my_list) ``` -`filter()` returns an iterator in which the elements of `my_list` are included, for which `my_function` returns `True`. An iterator is a special object that enables you to iterate over the elements of a collection, like a list. +`filter()` takes a function as its first argument and an iterable as its second argument. It returns an iterator, which is a special object that enables you to iterate over the elements of a collection, like a list. + +The result of the example above is an iterator containing the elements of `my_list` for which `my_function` returns `True`. Within the `filter_expenses_by_category` function, call `filter()` passing the `lambda` function you wrote in the previous step as the first argument and the `expenses` list as the second argument. # --hints-- -You should have `filter(lambda expense: expense['category'] == category, expenses)` in your `filter_expenses_by_category` function. +You should call `filter()` inside the `filter_expenses_by_category` function. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "filter_expenses_by_category"); - const {function_body} = foo; - assert(function_body.match(/^\s+filter\s*\(\s*lambda\s+expense\s*:\s*expense\s*\[\s*("|')category\1\s*\]\s*==\s*category\s*,\s*expenses\s*\)/m)); - } -}) +({ test: () => assert(runPython(`len(_Node(_code).find_function("filter_expenses_by_category").find_calls("filter")) == 1`)) }) +``` + +You should pass `lambda expense: expense['category'] == category` as the first argument to the `filter()` call. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("filter_expenses_by_category").find_calls("filter")[0].find_call_args()[0].is_equivalent("lambda expense: expense['category'] == category")`)) }) +``` + +You should pass `expenses` as the second argument to the `filter()` call. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("filter_expenses_by_category").find_calls("filter")[0].find_call_args()[1].is_equivalent("expenses")`)) }) ``` # --seed-- @@ -39,14 +46,14 @@ You should have `filter(lambda expense: expense['category'] == category, expense ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + --fcc-editable-region-- def filter_expenses_by_category(expenses, category): lambda expense: expense['category'] == category diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md index 31bdb26a2b4..99c08f3e7d1 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md @@ -1,8 +1,8 @@ --- id: 658244fdf4b0265334711664 -title: Step 22 +title: Step 23 challengeType: 20 -dashedName: step-22 +dashedName: step-23 --- # --description-- @@ -14,14 +14,7 @@ Finally, return the result of the `filter()` call. You should return the result of the `filter()` call from your `filter_expenses_by_category` function. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "filter_expenses_by_category"); - const {function_body} = foo; - assert(function_body.match(/^\s+return\s+filter\s*\(\s*lambda\s+expense\s*:\s*expense\s*\[\s*("|')category\1\s*\]\s*==\s*category\s*,\s*expenses\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("filter_expenses_by_category").has_return("filter(lambda expense: expense['category'] == category, expenses)")`)) }) ``` # --seed-- @@ -31,14 +24,14 @@ You should return the result of the `filter()` call from your `filter_expenses_b ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + --fcc-editable-region-- def filter_expenses_by_category(expenses, category): filter(lambda expense: expense['category'] == category, expenses) diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md index 3209e6c77c5..a2f8efceb9a 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md @@ -1,8 +1,8 @@ --- id: 65824561f3478e5371a33ae5 -title: Step 23 +title: Step 24 challengeType: 20 -dashedName: step-23 +dashedName: step-24 --- # --description-- @@ -19,6 +19,8 @@ You should define a function named `main()` without parameters. ({ test: () => assert(runPython(` import inspect inspect.isfunction(main) + sig = str(inspect.signature(main)) + sig == '()' `)) }) ``` @@ -26,12 +28,7 @@ You should define a function named `main()` without parameters. You should move the `expenses` list inside the `main()` function body. ```js -({ test: () => assert(runPython(` - import inspect - sig = str(inspect.signature(main)) - sig == '()' - `)) -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_body().is_equivalent("expenses = []")`)) }) ``` # --seed-- @@ -41,14 +38,14 @@ You should move the `expenses` list inside the `main()` function body. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) --fcc-editable-region-- diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md index 365e4b886ce..5471bb36c92 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md @@ -1,8 +1,8 @@ --- id: 658246c28575d653d1f89b59 -title: Step 24 +title: Step 25 challengeType: 20 -dashedName: step-24 +dashedName: step-25 --- # --description-- @@ -18,30 +18,16 @@ Below the `expenses` list, create a `while` loop. Use `True` for the condition, # --hints-- -You should have `while True:` in your `main()` function. +You should create a `while` loop using `True` as the condition within your `main()` function. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+while\s+True\s*:/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_conditions()[0].is_equivalent("True")`)) }) ``` -You should have `print('\nExpense Tracker')` in your `while` loop. +You should print `'\nExpense Tracker'` in your `while` loop. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+print\s*\(\s*("|')\\nExpense\s*Tracker\1\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_calls("print")[0].is_equivalent("print('\\\\nExpense Tracker')")`)) }) ``` # --seed-- @@ -51,19 +37,19 @@ You should have `print('\nExpense Tracker')` in your `while` loop. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) --fcc-editable-region-- def main(): expenses = [] - + --fcc-editable-region-- ``` diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md index 1b258f292ea..97d773f5cb8 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md @@ -1,29 +1,26 @@ --- id: 65824872894f59546e3084e2 -title: Step 25 +title: Step 26 challengeType: 20 -dashedName: step-25 +dashedName: step-26 --- # --description-- -The `while` loop you created in the previous step is an infinite loop that will allow the program to continuously present menu options until the user decides to exit. +The `while` loop you created in the previous step is an infinite loop that will allow the program to continuously present menu options until the user decides to exit. -After the `print()` call, add another one to print the string `'1. Add an expense'`. +After the `print()` call, add another `print()` call to print the string `'1. Add an expense'`. # --hints-- -You should have `print('1. Add an expense')` in your `while` loop. +You should print `'1. Add an expense'` within your `while` loop after the existing `print()` call. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+print\s*\(\s*("|')1\.\sAdd\san\sexpense\1\s*\)/m)); - } -}) +({ test: () => assert(runPython(` +call_lst = _Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_calls("print") +test_lst = ["print('\\\\nExpense Tracker')", "print('1. Add an expense')"] +all(call_lst[n].is_equivalent(i) for n, i in enumerate(test_lst)) +`)) }) ``` # --seed-- @@ -33,14 +30,14 @@ You should have `print('1. Add an expense')` in your `while` loop. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) @@ -49,6 +46,6 @@ def main(): --fcc-editable-region-- while True: print('\nExpense Tracker') - + --fcc-editable-region-- ``` diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md index 29575b7375a..bee24b42de5 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md @@ -1,8 +1,8 @@ --- id: 65824a1b16631c54fa524154 -title: Step 26 +title: Step 27 challengeType: 20 -dashedName: step-26 +dashedName: step-27 --- # --description-- @@ -11,17 +11,14 @@ Next, add another `print()` call and pass the string `'2. List all expenses'`. # --hints-- -You should have `print('2. List all expenses')` in your `while` loop. +You should print `'2. List all expenses'` in your `while` loop after the existing `print()` calls. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+print\s*\(\s*("|')2\.\sList\sall\sexpenses\1\s*\)/m)); - } -}) +({ test: () => assert(runPython(` +call_lst = _Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_calls("print") +test_lst = ["print('\\\\nExpense Tracker')", "print('1. Add an expense')", "print('2. List all expenses')"] +all(call_lst[n].is_equivalent(i) for n, i in enumerate(test_lst)) +`)) }) ``` # --seed-- @@ -31,14 +28,14 @@ You should have `print('2. List all expenses')` in your `while` loop. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) @@ -48,6 +45,6 @@ def main(): while True: print('\nExpense Tracker') print('1. Add an expense') - + --fcc-editable-region-- ``` diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md index 6b2bc6ffaee..132862fc6fe 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md @@ -1,53 +1,44 @@ --- id: 65824c7b4e2da85597693dcf -title: Step 27 +title: Step 28 challengeType: 20 -dashedName: step-27 +dashedName: step-28 --- # --description-- -Provide the other menu options by printing the following three strings in your `while` loop: `'3. Show total expenses'`, `'4. Filter expenses by category'`, and `'5. Exit'`. +Provide the other menu options by printing the following three strings in your `while` loop: `'3. Show total expenses'`, `'4. Filter expenses by category'`, and `'5. Exit'`. Keep adding the `print()` calls in order. # --hints-- You should have `print('3. Show total expenses')` in your `while` loop. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+print\s*\(\s*("|')3\.\sShow\stotal\sexpenses\1\s*\)/m)); - } -}) +({ test: () => assert(runPython(` +call_lst = _Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_calls("print") +test_lst = ["print('\\\\nExpense Tracker')", "print('1. Add an expense')", "print('2. List all expenses')", "print('3. Show total expenses')"] +all(call_lst[n].is_equivalent(i) for n, i in enumerate(test_lst)) +`)) }) ``` You should have `print('4. Filter expenses by category')` in your `while` loop. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+print\s*\(\s*("|')4\.\sFilter\sexpenses\sby\scategory\1\s*\)/m)); - } -}) +({ test: () => assert(runPython(` +call_lst = _Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_calls("print") +test_lst = ["print('\\\\nExpense Tracker')", "print('1. Add an expense')", "print('2. List all expenses')", "print('3. Show total expenses')", "print('4. Filter expenses by category')"] +all(call_lst[n].is_equivalent(i) for n, i in enumerate(test_lst)) +`)) }) ``` You should have `print('5. Exit')` in your `while` loop. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+print\s*\(\s*("|')5\.\sExit\1\s*\)/m)); - } -}) +({ test: () => assert(runPython(` +call_lst = _Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_calls("print") +test_lst = ["print('\\\\nExpense Tracker')", "print('1. Add an expense')", "print('2. List all expenses')", "print('3. Show total expenses')", "print('4. Filter expenses by category')", "print('5. Exit')"] +all(call_lst[n].is_equivalent(i) for n, i in enumerate(test_lst)) +`)) }) ``` # --seed-- @@ -57,14 +48,14 @@ You should have `print('5. Exit')` in your `while` loop. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) @@ -75,6 +66,6 @@ def main(): print('\nExpense Tracker') print('1. Add an expense') print('2. List all expenses') - + --fcc-editable-region-- ``` diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md index 32fe6ab7e0b..392024966fb 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md @@ -1,8 +1,8 @@ --- id: 65824dfdb6815d563b2d3256 -title: Step 28 +title: Step 29 challengeType: 20 -dashedName: step-28 +dashedName: step-29 --- # --description-- @@ -13,17 +13,18 @@ Inside your `while` loop, call the `input()` function passing the string `'Enter # --hints-- -You should have `choice = input('Enter your choice: ')` in your `while` loop. +You should declare a variable named `choice` within your `while` loop. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+choice\s*=\s*input\s*\(\s*("|')Enter\syour\schoice:\s\1\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].has_variable("choice") +`)) }) +``` + +You should assign the result of the `input()` function, with the string `'Enter your choice: '` as its argument, to your `choice` variable. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_variable("choice").is_equivalent("choice = input('Enter your choice: ')") +`)) }) ``` # --seed-- @@ -33,17 +34,17 @@ You should have `choice = input('Enter your choice: ')` in your `while` loop. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) - + --fcc-editable-region-- def main(): expenses = [] @@ -54,6 +55,6 @@ def main(): print('3. Show total expenses') print('4. Filter expenses by category') print('5. Exit') - + --fcc-editable-region-- ``` diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md index 0940266004e..240d01654e0 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md @@ -1,8 +1,8 @@ --- id: 6582507654b3ed5712341382 -title: Step 29 +title: Step 30 challengeType: 20 -dashedName: step-29 +dashedName: step-30 --- # --description-- @@ -15,30 +15,27 @@ Inside the `if` statement body, declare a variable `amount` and assign it an emp # --hints-- -You should have `if choice == '1':` in your `while` loop: +You should create an `if` statement that checks if `choice` is equal to `'1'` in your `while` loop. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+if\s+choice\s*==\s*("|')1\1\s*:/m)); - } -}) +({ test: () => assert(runPython(` +cond = _Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_conditions()[0] +cond.is_equivalent("choice == '1'") or cond.is_equivalent("'1' == choice") +`)) }) ``` -You should have `amount = input()` in your `if` statement body: +You should declare a variable named `amount` in your `if` statement body. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+if\s+choice\s*==\s*("|')1\1\s*:\s*amount\s*=\s*input\s*\(\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[0].has_variable("amount") +`)) }) +``` + +You should assign an empty `input()` call to your `amount` variable. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[0].find_variable("amount").is_equivalent("amount = input()") +`)) }) ``` # --seed-- @@ -48,17 +45,17 @@ You should have `amount = input()` in your `if` statement body: ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) - + --fcc-editable-region-- def main(): expenses = [] @@ -69,7 +66,7 @@ def main(): print('3. Show total expenses') print('4. Filter expenses by category') print('5. Exit') - + choice = input('Enter your choice: ') --fcc-editable-region-- diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md index 2b88a233291..6d76794bd32 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md @@ -1,8 +1,8 @@ --- id: 658252f6b1526d57b103d48a -title: Step 30 +title: Step 31 challengeType: 20 -dashedName: step-30 +dashedName: step-31 --- # --description-- @@ -13,17 +13,11 @@ Pass the string `'Enter amount: '` to your empty `input()` call, so you can stor # --hints-- -You should have `amount = input('Enter amount: ')` in your `if` statement. +You should pass `'Enter amount: '` to the `input()` call assigned to the `amount` variable. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+if\s+choice\s*==\s*("|')1\1\s*:\s*amount\s*=\s*input\s*\(\s*("|')Enter amount:\s\2\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[0].find_variable("amount").is_equivalent("amount = input('Enter amount: ')") +`)) }) ``` # --seed-- @@ -33,18 +27,17 @@ You should have `amount = input('Enter amount: ')` in your `if` statement. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) - ---fcc-editable-region-- + def main(): expenses = [] while True: @@ -54,9 +47,9 @@ def main(): print('3. Show total expenses') print('4. Filter expenses by category') print('5. Exit') - + choice = input('Enter your choice: ') - +--fcc-editable-region-- if choice == '1': amount = input() --fcc-editable-region-- diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md index bd45260c728..8818d086821 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md @@ -1,8 +1,8 @@ --- id: 658254db6e12485a48130f57 -title: Passo 31 +title: Step 32 challengeType: 20 -dashedName: step-31 +dashedName: step-32 --- # --description-- @@ -13,17 +13,11 @@ Pass `input('Enter amount: ')` to the `float()` function. # --hints-- -You should have `amount = float(input('Enter amount: '))` in your `if` statement. +You should pass `input('Enter amount: ')` to the `float()` function in the assignment of `amount`. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+if\s+choice\s*==\s*("|')1\1\s*:\s*amount\s*=\s*float\s*\(\s*input\s*\(\s*("|')Enter\samount:\s\2\s*\)\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[0].find_variable("amount").is_equivalent("amount = float(input('Enter amount: '))") +`)) }) ``` # --seed-- @@ -33,17 +27,17 @@ You should have `amount = float(input('Enter amount: '))` in your `if` statement ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) - + --fcc-editable-region-- def main(): expenses = [] @@ -54,9 +48,9 @@ def main(): print('3. Show total expenses') print('4. Filter expenses by category') print('5. Exit') - + choice = input('Enter your choice: ') - + if choice == '1': amount = input('Enter amount: ') --fcc-editable-region-- diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md index b8b4c7503e1..520834f9bfc 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md @@ -1,27 +1,26 @@ --- id: 658255d5f955175b270f251d -title: Step 32 +title: Step 33 challengeType: 20 -dashedName: step-32 +dashedName: step-33 --- # --description-- -Inside your `if` statement, create a variable `category` to store the expense category. Assign it `input('Enter category: ')`. +Inside your `if` statement, create a variable named `category` to store the expense category. Assign it a call to `input()` and use the `'Enter category: '` as the argument. # --hints-- -You should have `category = input('Enter category: ')` in your `if` statement. +You should declare a variable named `category` in your `if` statement. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+if\s+choice\s*==\s*("|')1\1\s*:\s*amount\s*=\s*float\s*\(\s*input\s*\(\s*("|')Enter\samount:\s\2\s*\)\s*\)\s*category\s*=\s*input\s*\(\s*("|')Enter\scategory:\s\3\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[0].has_variable("category")`)) }) +``` + +You should assign `input('Enter category: ')` to your `category` variable. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[0].find_variable("category").is_equivalent("category = input('Enter category: ')")`)) }) ``` # --seed-- @@ -31,17 +30,17 @@ You should have `category = input('Enter category: ')` in your `if` statement. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) - + def main(): expenses = [] @@ -52,11 +51,11 @@ def main(): print('3. Show total expenses') print('4. Filter expenses by category') print('5. Exit') - + choice = input('Enter your choice: ') --fcc-editable-region-- if choice == '1': amount = float(input('Enter amount: ')) - + --fcc-editable-region-- ``` diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md index 15a853b8356..2923664b6db 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md @@ -1,15 +1,15 @@ --- id: 6582575b8089f85b8b92d7c8 -title: Step 33 +title: Step 34 challengeType: 20 -dashedName: step-33 +dashedName: step-34 --- # --description-- -After getting the expense details, you need to call the `add_expense` function to add the new expense to the `expenses` list. +Once you have the expense details, you need to call the `add_expense` function to add the new expense to the `expenses` list. -After getting the `amount` and `category` using `input()`, call the `add_expense` function, passing three arguments: `expenses`, `amount` and `category`. +After getting the `amount` and `category` using `input()`, call the `add_expense` function, passing three arguments: `expenses`, `amount` and `category`. - `expenses` is the empty list created in the main function earlier in this project. - `amount` is the amount of the expense. @@ -17,17 +17,22 @@ After getting the `amount` and `category` using `input()`, call the `add_expense # --hints-- -You should have `add_expense(expenses, amount, category)` in your `if` statement. +You should call the `add_expense()` function within your `if` statement. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+if\s+choice\s*==\s*("|')1\1\s*:\s*amount\s*=\s*float\s*\(\s*input\s*\(\s*("|')Enter\samount:\s\2\s*\)\s*\)\s*category\s*=\s*input\s*\(\s*("|')Enter\scategory:\s\3\s*\)\s*add_expense\s*\(\s*expenses\s*,\s*amount\s*,\s*category\s*\)/m)); - } -}) +({ test: () => assert(runPython(`len(_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[0].find_calls("add_expense")) == 1`)) }) +``` + +You should pass three arguments to your `add_expense()` call: `expenses`, `amount`, and `category`. The order matters. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[0].has_call("add_expense(expenses, amount, category)")`)) }) +``` + +Your `add_expense()` call should come after the assignment of `amount` and `category`. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[0].is_equivalent("amount = float(input('Enter amount: '))\\ncategory = input('Enter category: ')\\nadd_expense(expenses, amount, category)")`)) }) ``` # --seed-- @@ -37,17 +42,17 @@ You should have `add_expense(expenses, amount, category)` in your `if` statement ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) - + def main(): expenses = [] @@ -58,12 +63,12 @@ def main(): print('3. Show total expenses') print('4. Filter expenses by category') print('5. Exit') - + choice = input('Enter your choice: ') --fcc-editable-region-- if choice == '1': amount = float(input('Enter amount: ')) category = input('Enter category: ') - + --fcc-editable-region-- ``` diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md index 0511583a76a..50cb2f6a557 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md @@ -1,42 +1,31 @@ --- id: 658258c0e5fbe85c14c060cf -title: Step 34 +title: Step 35 challengeType: 20 -dashedName: step-34 +dashedName: step-35 --- # --description-- -To list all expenses, you can use an `elif` statement after an `if` statement. The `elif` checks additional conditions and only works following an `if` statement. +To list all expenses, you can use an `elif` clause after an `if` statement. The `elif` checks additional conditions and only works following an `if` statement. -Create an `elif` statement to check if the user's choice equals the string `2`. Inside the `elif` statement, print the string `'\nAll Expenses:'`. +Create an `elif` clause to check if the user's choice equals the string `'2'`. Inside the `elif` clause, print the string `'\nAll Expenses:'`. # --hints-- -You should have `elif choice == '2':` after your `if` statement. +You should create an `elif` clause that checks that `choice` is equal to `'2'` after your `if` statement. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+elif\s+choice\s*==\s*("|')2\1\s*:/m)); - } -}) +({ test: () => assert(runPython(` +cond = _Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_conditions()[1] +cond.is_equivalent("choice == '2'") or cond.is_equivalent("'2' == choice") +`)) }) ``` -You should have `print('\nAll Expenses:')` inside your `elif` statement. +You should print `'\nAll Expenses:'` inside your `elif` clause. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+elif\s+choice\s*==\s*("|')2\1\s*:\s*print\s*\(\s*("|')\\nAll\sExpenses:\2\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[1].has_call("print('\\\\nAll Expenses:')")`)) }) ``` # --seed-- @@ -46,17 +35,17 @@ You should have `print('\nAll Expenses:')` inside your `elif` statement. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) - + def main(): expenses = [] @@ -67,13 +56,13 @@ def main(): print('3. Show total expenses') print('4. Filter expenses by category') print('5. Exit') - + choice = input('Enter your choice: ') --fcc-editable-region-- if choice == '1': amount = float(input('Enter amount: ')) category = input('Enter category: ') add_expense(expenses, amount, category) - + --fcc-editable-region-- ``` diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md index 8db118990af..28de93f6f77 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md @@ -1,8 +1,8 @@ --- id: 65825a9520a0795c8afbef50 -title: Step 35 +title: Step 36 challengeType: 20 -dashedName: step-35 +dashedName: step-36 --- # --description-- @@ -11,17 +11,16 @@ After the `print()` call, call the `print_expenses` function to display all the # --hints-- -You should have `print_expenses(expenses)` in your `elif` statement. +You should call the `print_expenses()` function within your `elif` clause. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+elif\s+choice\s*==\s*("|')2\1\s*:\s*print\s*\(\s*("|')\\nAll\sExpenses:\2\s*\)\s*print\s*_expenses\s*\(\s*expenses\s*\)/m)); - } -}) +({ test: () => assert(runPython(`len(_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[1].find_calls("print_expenses")) == 1`)) }) +``` + +You should pass the `expenses` list as the argument to your `print_expenses()` call. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[1].has_call("print_expenses(expenses)")`)) }) ``` # --seed-- @@ -31,17 +30,17 @@ You should have `print_expenses(expenses)` in your `elif` statement. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) - + def main(): expenses = [] @@ -52,7 +51,7 @@ def main(): print('3. Show total expenses') print('4. Filter expenses by category') print('5. Exit') - + choice = input('Enter your choice: ') if choice == '1': @@ -62,6 +61,6 @@ def main(): --fcc-editable-region-- elif choice == '2': print('\nAll Expenses:') - + --fcc-editable-region-- ``` diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md index 77331e9840b..1322922a208 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md @@ -1,42 +1,31 @@ --- id: 65825b758fe85a5cebabc8c5 -title: Step 36 +title: Step 37 challengeType: 20 -dashedName: step-36 +dashedName: step-37 --- # --description-- -To show the total expenses, create an `elif` statement that checks if `choice == '3'`. +To show the total expenses, create an `elif` statement that checks if `choice == '3'`. If it's true, it means the user wants to see the total expenses. So call `print()` and pass the string `'\nTotal Expenses: '` as the first argument and `total_expenses(expenses)` as the second argument. # --hints-- -You should have `elif choice == '3':` in your code. +You should create an `elif` clause that checks if `choice == '3'`. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert.match(function_body, /\s+elif\s+choice\s*==\s*("|')3\1\s*:/); - } -}) +({ test: () => assert(runPython(` +cond = _Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_conditions()[2] +cond.is_equivalent("choice == '3'") or cond.is_equivalent("'3' == choice") +`)) }) ``` -You should have `print('\nTotal Expenses: ', total_expenses(expenses))` in your `elif` statement. +You should print `'\nTotal Expenses: ', total_expenses(expenses)` in your new `elif` clause. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+elif\s+choice\s*==\s*("|')3\1\s*:\s*print\s*\(\s*("|')\\nTotal\sExpenses:\s\2\s*,\s*total_expenses\s*\(\s*expenses\s*\)\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[2].has_call("print('\\\\nTotal Expenses: ', total_expenses(expenses))")`)) }) ``` # --seed-- @@ -46,17 +35,17 @@ You should have `print('\nTotal Expenses: ', total_expenses(expenses))` in your ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) - + def main(): expenses = [] @@ -67,7 +56,7 @@ def main(): print('3. Show total expenses') print('4. Filter expenses by category') print('5. Exit') - + choice = input('Enter your choice: ') if choice == '1': @@ -78,6 +67,6 @@ def main(): elif choice == '2': print('\nAll Expenses:') print_expenses(expenses) - + --fcc-editable-region-- ``` diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md index 4177eb92bc7..9436b4f73c1 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md @@ -1,40 +1,35 @@ --- id: 65825cda2668995d5168e37c -title: Passo 37 +title: Step 38 challengeType: 20 -dashedName: step-37 +dashedName: step-38 --- # --description-- -Create another `elif` statement that checks if `choice == '4'`. Inside the new `elif`, create a variable `category` and assign it `input('Enter category to filter: ')` to filter the expense category. +Create another `elif` clause that checks if `choice == '4'`. Inside the new `elif`, create a variable `category` and assign it `input('Enter category to filter: ')` to filter the expense category. # --hints-- -You should have `elif choice == '4':` in your code. +You should create an `elif` clause that checks if `choice == '4'`. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+elif\s+choice\s*==\s*("|')4\1\s*:/m)); - } -}) +({ test: () => assert(runPython(` +cond = _Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_conditions()[3] +cond.is_equivalent("choice == '4'") or cond.is_equivalent("'4' == choice") +`)) }) ``` -You should have `category = input('Enter category to filter: ')` in your new `elif` statement. +You should declared a variable named `category` in your new `elif` clause. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+elif\s+choice\s*==\s*("|')4\1\s*:\s*category\s*=\s*input\s*\(\s*("|')Enter\scategory\sto\sfilter:\s\2\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[3].has_variable("category")`)) }) +``` + +You should assign `input('Enter category to filter: ')` to your `category` variable. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[3].find_variable("category").is_equivalent("category = input('Enter category to filter: ')")`)) }) ``` # --seed-- @@ -44,17 +39,17 @@ You should have `category = input('Enter category to filter: ')` in your new `el ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) - + def main(): expenses = [] @@ -65,7 +60,7 @@ def main(): print('3. Show total expenses') print('4. Filter expenses by category') print('5. Exit') - + choice = input('Enter your choice: ') if choice == '1': @@ -79,6 +74,6 @@ def main(): --fcc-editable-region-- elif choice == '3': print('\nTotal Expenses: ', total_expenses(expenses)) - + --fcc-editable-region-- ``` diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md index e0dc7f00d81..c771cc30551 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md @@ -1,8 +1,8 @@ --- id: 65825e96b5db5f5dee6bf57c -title: Step 38 +title: Step 39 challengeType: 20 -dashedName: step-38 +dashedName: step-39 --- # --description-- @@ -11,17 +11,10 @@ After getting the category, print the following f-string `f'\nExpenses for {cate # --hints-- -You should print `f'\nExpenses for {category}:'` inside the `elif` statement. +You should print `f'\nExpenses for {category}:'` after the assignment of `category`. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+elif\s+choice\s*==\s*("|')4\1\s*:\s*category\s*=\s*input\s*\(\s*("|')Enter\scategory\sto\sfilter:\s\2\s*\)\s*print\s*\(\s*f("|')\\nExpenses for \{\s*category\s*\}:\3\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[3].is_equivalent("category = input('Enter category to filter: ')\\nprint(f'\\\\nExpenses for {category}:')")`)) }) ``` # --seed-- @@ -31,17 +24,17 @@ You should print `f'\nExpenses for {category}:'` inside the `elif` statement. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) - + def main(): expenses = [] @@ -52,7 +45,7 @@ def main(): print('3. Show total expenses') print('4. Filter expenses by category') print('5. Exit') - + choice = input('Enter your choice: ') if choice == '1': @@ -69,6 +62,6 @@ def main(): --fcc-editable-region-- elif choice == '4': category = input('Enter category to filter: ') - + --fcc-editable-region-- ``` diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md index 69c26e53bbf..5a529fbe4bd 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md @@ -1,8 +1,8 @@ --- id: 6582601b2987045e8e7da994 -title: Step 39 +title: Step 40 challengeType: 20 -dashedName: step-39 +dashedName: step-40 --- # --description-- @@ -11,17 +11,22 @@ After your `print()` call, you need to filter the expenses and print the filtere # --hints-- -You should have `expenses_from_category = filter_expenses_by_category(expenses, category)` in your `elif` statement. +You should declare a variable named `expenses_from_category` in your `elif` clause. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+elif\s+choice\s*==\s*("|')4\1\s*:\s*category\s*=\s*input\s*\(\s*("|')Enter\scategory\sto\sfilter:\s\2\s*\)\s*print\s*\(\s*f("|')\\nExpenses for \{\s*category\s*\}:\3\s*\)\s*expenses_from_category\s*=\s*filter_expenses_by_category\s*\(\s*expenses\s*,\s*category\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[3].has_variable("expenses_from_category")`)) }) +``` + +You should call `filter_expenses_by_category()` passing `expenses` and `category` as the arguments and assign it to your `expenses_from_category` variable. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[3].find_variable("expenses_from_category").is_equivalent("expenses_from_category = filter_expenses_by_category(expenses, category)")`)) }) +``` + +Your `expenses_from_category` variable should come after the `print()` call. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[3].is_equivalent("category = input('Enter category to filter: ')\\nprint(f'\\\\nExpenses for {category}:')\\nexpenses_from_category = filter_expenses_by_category(expenses, category)")`)) }) ``` # --seed-- @@ -31,17 +36,17 @@ You should have `expenses_from_category = filter_expenses_by_category(expenses, ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) - + def main(): expenses = [] @@ -52,7 +57,7 @@ def main(): print('3. Show total expenses') print('4. Filter expenses by category') print('5. Exit') - + choice = input('Enter your choice: ') if choice == '1': @@ -70,6 +75,6 @@ def main(): elif choice == '4': category = input('Enter category to filter: ') print(f'\nExpenses for {category}:') - + --fcc-editable-region-- ``` diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md index b7a76116f30..746e7779537 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md @@ -1,27 +1,26 @@ --- id: 6582622cb6c11a5f4c5d79b4 -title: Step 40 +title: Step 41 challengeType: 20 -dashedName: step-40 +dashedName: step-41 --- # --description-- -Still within the `elif` statement, pass `expenses_from_category` iterator to a `print_expenses` call. +Still within the `elif` clause, pass the `expenses_from_category` iterator to a `print_expenses` call. # --hints-- -You should have `print_expenses(expenses_from_category)` in your code. +You should call `print_expenses()` passing `expenses_from_category` as the argument in your `elif` clause. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+elif\s+choice\s*==\s*("|')4\1\s*:\s*category\s*=\s*input\s*\(\s*("|')Enter\scategory\sto\sfilter:\s\2\s*\)\s*print\s*\(\s*f("|')\\nExpenses for \{\s*category\s*\}:\3\s*\)\s*expenses_from_category\s*=\s*filter_expenses_by_category\s*\(\s*expenses\s*,\s*category\s*\)\s*print_expenses\s*\(\s*expenses_from_category\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[3].has_call("print_expenses(expenses_from_category)")`)) }) +``` + +Your `print_expenses()` call should come after the `expenses_from_category` variable. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[3].is_equivalent("category = input('Enter category to filter: ')\\nprint(f'\\\\nExpenses for {category}:')\\nexpenses_from_category = filter_expenses_by_category(expenses, category)\\nprint_expenses(expenses_from_category)")`)) }) ``` # --seed-- @@ -31,17 +30,17 @@ You should have `print_expenses(expenses_from_category)` in your code. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) - + def main(): expenses = [] @@ -52,7 +51,7 @@ def main(): print('3. Show total expenses') print('4. Filter expenses by category') print('5. Exit') - + choice = input('Enter your choice: ') if choice == '1': @@ -71,6 +70,6 @@ def main(): category = input('Enter category to filter: ') print(f'\nExpenses for {category}:') expenses_from_category = filter_expenses_by_category(expenses, category) - + --fcc-editable-region-- ``` diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md index a7dc82d4f78..76316b1ba48 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md @@ -1,42 +1,31 @@ --- id: 6582687859366a618424d84b -title: Step 41 +title: Step 42 challengeType: 20 -dashedName: step-41 +dashedName: step-42 --- # --description-- -To provide a way to exit the program, use another `elif` statement to check if `choice` equals the string `'5'`. +To provide a way to exit the program, use another `elif` clause to check if `choice` equals the string `'5'`. -Inside the new `elif` statement, print the string `'Exiting the program.'` to show that the program is terminating its execution. +Inside the new `elif` clause, print the string `'Exiting the program.'` to show that the program is terminating its execution. # --hints-- -You should have `elif choice == '5':` in your code. +You should create an `elif` clause that checks if `choice == '5'`. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+elif\s+choice\s*==\s*("|')5\1\s*:/m)); - } -}) +({ test: () => assert(runPython(` +cond = _Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_conditions()[4] +cond.is_equivalent("choice == '5'") or cond.is_equivalent("'5' == choice") +`)) }) ``` -You should print `'Exiting the program.'` in your new `elif` statement. +You should print `'Exiting the program.'` in your new `elif` clause. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+elif\s+choice\s*==\s*("|')5\1\s*:\s*print\s*\(\s*("|')Exiting\sthe\sprogram.\2\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[4].has_call("print('Exiting the program.')")`)) }) ``` # --seed-- @@ -46,17 +35,17 @@ You should print `'Exiting the program.'` in your new `elif` statement. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) - + def main(): expenses = [] @@ -67,7 +56,7 @@ def main(): print('3. Show total expenses') print('4. Filter expenses by category') print('5. Exit') - + choice = input('Enter your choice: ') if choice == '1': @@ -87,6 +76,6 @@ def main(): print(f'\nExpenses for {category}:') expenses_from_category = filter_expenses_by_category(expenses, category) print_expenses(expenses_from_category) - + --fcc-editable-region-- ``` diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md index ee34b84f93a..465c1008e5a 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md @@ -1,27 +1,20 @@ --- id: 65826a6e9d189a623141c726 -title: Step 42 +title: Step 43 challengeType: 20 -dashedName: step-42 +dashedName: step-43 --- # --description-- -Finally, to stop the execution of the `while` loop, add the `break` statement inside your last `elif` statement. +Finally, to stop the execution of the `while` loop, add the `break` statement inside your last `elif` clause. # --hints-- -You should have a `break` statement inside your last `elif`. +You should have a `break` statement after the `print()` call inside your last `elif` clause. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+break/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[4].is_equivalent("print('Exiting the program.')\\nbreak")`)) }) ``` # --seed-- @@ -31,17 +24,17 @@ You should have a `break` statement inside your last `elif`. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) - + def main(): expenses = [] @@ -52,7 +45,7 @@ def main(): print('3. Show total expenses') print('4. Filter expenses by category') print('5. Exit') - + choice = input('Enter your choice: ') if choice == '1': @@ -75,6 +68,6 @@ def main(): --fcc-editable-region-- elif choice == '5': print('Exiting the program.') - + --fcc-editable-region-- ``` diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md index 6dc2b7f17f5..b8403971842 100644 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md @@ -1,13 +1,15 @@ --- id: 65826af5b226a5628aa154b1 -title: Step 43 +title: Step 44 challengeType: 20 -dashedName: step-43 +dashedName: step-44 --- # --description-- -Finally, call your `main()` function, and try the expense tracker program. +Finally, call your `main()` function, and try the expense tracker program in the console. + +With that, the expense tracker project is complete! # --hints-- @@ -24,17 +26,17 @@ assert.match(code, /^main\s*\(\s*\)/m) ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) - + def main(): expenses = [] @@ -45,7 +47,63 @@ def main(): print('3. Show total expenses') print('4. Filter expenses by category') print('5. Exit') + + choice = input('Enter your choice: ') + if choice == '1': + amount = float(input('Enter amount: ')) + category = input('Enter category: ') + add_expense(expenses, amount, category) + + elif choice == '2': + print('\nAll Expenses:') + print_expenses(expenses) + + elif choice == '3': + print('\nTotal Expenses: ', total_expenses(expenses)) + + elif choice == '4': + category = input('Enter category to filter: ') + print(f'\nExpenses for {category}:') + expenses_from_category = filter_expenses_by_category(expenses, category) + print_expenses(expenses_from_category) + + elif choice == '5': + print('Exiting the program.') + break + +--fcc-editable-region-- + +--fcc-editable-region-- +``` + +# --solutions-- + +```py +def add_expense(expenses, amount, category): + expenses.append({'amount': amount, 'category': category}) + +def print_expenses(expenses): + for expense in expenses: + print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') + +def total_expenses(expenses): + return sum(map(lambda expense: expense['amount'], expenses)) + +def filter_expenses_by_category(expenses, category): + return filter(lambda expense: expense['category'] == category, expenses) + + +def main(): + expenses = [] + while True: + print('\nExpense Tracker') + print('1. Add an expense') + print('2. List all expenses') + print('3. Show total expenses') + print('4. Filter expenses by category') + print('5. Exit') + choice = input('Enter your choice: ') if choice == '1': @@ -70,7 +128,6 @@ def main(): print('Exiting the program.') break ---fcc-editable-region-- +main() ---fcc-editable-region-- ``` diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826befd75db5632bd73df6.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826befd75db5632bd73df6.md deleted file mode 100644 index c5daf97b54e..00000000000 --- a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826befd75db5632bd73df6.md +++ /dev/null @@ -1,145 +0,0 @@ ---- -id: 65826befd75db5632bd73df6 -title: Step 44 -challengeType: 20 -dashedName: step-44 ---- - -# --description-- - -You can use the `__name__` variable to determine if a Python script is being run as the main program or if it is being imported as a module (code written in another Python file). - -If the value of `__name__` is set to `'__main__'`, it implies that the current script is the main program, and not a module. - -As a final step, create an `if` statement to check if `__name__ == '__main__'`, and move the `main()` call inside this block. - -With that, the expense tracker project is complete! - -# --hints-- - -You should have `if __name__ == '__main__':` in your code. - -```js -assert.match(code,/^if\s+__name__\s*==\s*("|')__main__\1\s*:/m); -``` - -Your `main()` call should be inside the `if` statement. - -```js -assert.match(code, /^if\s+__name__\s*==\s*("|')__main__\1\s*:\s*main\s*\(\s*\)/m); -``` - -# --seed-- - -## --seed-contents-- - -```py -def add_expense(expenses, amount, category): - expenses.append({'amount': amount, 'category': category}) - -def print_expenses(expenses): - for expense in expenses: - print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - -def total_expenses(expenses): - return sum(map(lambda expense: expense['amount'], expenses)) - -def filter_expenses_by_category(expenses, category): - return filter(lambda expense: expense['category'] == category, expenses) - - -def main(): - expenses = [] - while True: - print('\nExpense Tracker') - print('1. Add an expense') - print('2. List all expenses') - print('3. Show total expenses') - print('4. Filter expenses by category') - print('5. Exit') - - choice = input('Enter your choice: ') - - if choice == '1': - amount = float(input('Enter amount: ')) - category = input('Enter category: ') - add_expense(expenses, amount, category) - - elif choice == '2': - print('\nAll Expenses:') - print_expenses(expenses) - - elif choice == '3': - print('\nTotal Expenses: ', total_expenses(expenses)) - - elif choice == '4': - category = input('Enter category to filter: ') - print(f'\nExpenses for {category}:') - expenses_from_category = filter_expenses_by_category(expenses, category) - print_expenses(expenses_from_category) - - elif choice == '5': - print('Exiting the program.') - break - ---fcc-editable-region-- -main() ---fcc-editable-region-- -``` - - -# --solutions-- - -```py -def add_expense(expenses, amount, category): - expenses.append({'amount': amount, 'category': category}) - -def print_expenses(expenses): - for expense in expenses: - print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - -def total_expenses(expenses): - return sum(map(lambda expense: expense['amount'], expenses)) - -def filter_expenses_by_category(expenses, category): - return filter(lambda expense: expense['category'] == category, expenses) - - -def main(): - expenses = [] - while True: - print('\nExpense Tracker') - print('1. Add an expense') - print('2. List all expenses') - print('3. Show total expenses') - print('4. Filter expenses by category') - print('5. Exit') - - choice = input('Enter your choice: ') - - if choice == '1': - amount = float(input('Enter amount: ')) - category = input('Enter category: ') - add_expense(expenses, amount, category) - - elif choice == '2': - print('\nAll Expenses:') - print_expenses(expenses) - - elif choice == '3': - print('\nTotal Expenses: ', total_expenses(expenses)) - - elif choice == '4': - category = input('Enter category to filter: ') - print(f'\nExpenses for {category}:') - expenses_from_category = filter_expenses_by_category(expenses, category) - print_expenses(expenses_from_category) - - elif choice == '5': - print('Exiting the program.') - break - -if __name__ == '__main__': - main() - -``` diff --git a/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/66314f2add0a8b57da5d6d91.md b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/66314f2add0a8b57da5d6d91.md new file mode 100644 index 00000000000..43669da4b07 --- /dev/null +++ b/curriculum/challenges/italian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/66314f2add0a8b57da5d6d91.md @@ -0,0 +1,43 @@ +--- +id: 66314f2add0a8b57da5d6d91 +title: Step 14 +challengeType: 20 +dashedName: step-14 +--- + +# --description-- + +You should see something like `` printed on the console, which is the string representation of the map object returned by `map()`. + +To obtain a readable output you need to turn the map object into a list. Do it by passing the `map()` call as the argument to the `list()` function. + +# --hints-- + +You should pass the `map()` call as the argument to the `list()` function. + +```js +({ test: () => assert(runPython(`_Node(_code).has_call("print(list(map(test, [2,3,5,8])))")`)) }) +``` + +# --seed-- + +## --seed-contents-- + +```py +def add_expense(expenses, amount, category): + expenses.append({'amount': amount, 'category': category}) + +def print_expenses(expenses): + for expense in expenses: + print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') + +def total_expenses(expenses): + pass + +--fcc-editable-region-- +test = lambda x: x * 2 +print(map(test, [2, 3, 5, 8])) +--fcc-editable-region-- + +expenses = [] +``` diff --git a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md index f71536a9b00..1719e6a44a6 100644 --- a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md +++ b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md @@ -2,7 +2,7 @@ id: 658238f7604f154ea9a23e1e title: ステップ 14 challengeType: 20 -dashedName: step-14 +dashedName: step-15 --- # --description-- diff --git a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md index c6a2f09681e..f7b3529ca3e 100644 --- a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md +++ b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md @@ -2,7 +2,7 @@ id: 65823b0167fd894f4a7ea60a title: ステップ 15 challengeType: 20 -dashedName: step-15 +dashedName: step-16 --- # --description-- diff --git a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md index 0683ce66a2e..1bae8814c1b 100644 --- a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md +++ b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md @@ -2,7 +2,7 @@ id: 65823bbbdb4eaa4f9d20a0fb title: ステップ 16 challengeType: 20 -dashedName: step-16 +dashedName: step-17 --- # --description-- diff --git a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md index da8b71aedad..d5521ea0f37 100644 --- a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md +++ b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md @@ -2,7 +2,7 @@ id: 65823cfc74aa564ffc460489 title: ステップ 17 challengeType: 20 -dashedName: step-17 +dashedName: step-18 --- # --description-- diff --git a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md index fa94bef4052..78da43618ae 100644 --- a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md +++ b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md @@ -2,7 +2,7 @@ id: 65823dde36392f505a39f7c7 title: ステップ 18 challengeType: 20 -dashedName: step-18 +dashedName: step-19 --- # --description-- diff --git a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md index c3f7035948a..a51f95259da 100644 --- a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md +++ b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md @@ -2,7 +2,7 @@ id: 65823e87c9741750a22085a7 title: ステップ 19 challengeType: 20 -dashedName: step-19 +dashedName: step-20 --- # --description-- diff --git a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md index 8fffb1ab6c9..bb37760476d 100644 --- a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md +++ b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md @@ -2,7 +2,7 @@ id: 65823ff0d4b991510fade1a8 title: ステップ 20 challengeType: 20 -dashedName: step-20 +dashedName: step-21 --- # --description-- diff --git a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md index b5c77364b94..3bff1222636 100644 --- a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md +++ b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md @@ -2,7 +2,7 @@ id: 65824111a09164518320088d title: ステップ 21 challengeType: 20 -dashedName: step-21 +dashedName: step-22 --- # --description-- diff --git a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md index 4aa076b9a16..530be671df3 100644 --- a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md +++ b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md @@ -2,7 +2,7 @@ id: 658244fdf4b0265334711664 title: ステップ 22 challengeType: 20 -dashedName: step-22 +dashedName: step-23 --- # --description-- diff --git a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md index 7922f995b8d..871ead794c5 100644 --- a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md +++ b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md @@ -2,7 +2,7 @@ id: 65824561f3478e5371a33ae5 title: ステップ 23 challengeType: 20 -dashedName: step-23 +dashedName: step-24 --- # --description-- diff --git a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md index 946fbcd0533..07ec8d09805 100644 --- a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md +++ b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md @@ -2,7 +2,7 @@ id: 658246c28575d653d1f89b59 title: ステップ 24 challengeType: 20 -dashedName: step-24 +dashedName: step-25 --- # --description-- diff --git a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md index 8a8996ac747..53b68ca97e2 100644 --- a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md +++ b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md @@ -2,7 +2,7 @@ id: 65824872894f59546e3084e2 title: ステップ 25 challengeType: 20 -dashedName: step-25 +dashedName: step-26 --- # --description-- diff --git a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md index 55a81d00806..050fa18bb37 100644 --- a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md +++ b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md @@ -2,7 +2,7 @@ id: 65824a1b16631c54fa524154 title: ステップ 26 challengeType: 20 -dashedName: step-26 +dashedName: step-27 --- # --description-- diff --git a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md index 25743e4d214..926f953ad0c 100644 --- a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md +++ b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md @@ -2,7 +2,7 @@ id: 65824c7b4e2da85597693dcf title: ステップ 27 challengeType: 20 -dashedName: step-27 +dashedName: step-28 --- # --description-- diff --git a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md index 6a6e7b65fda..86ed1f420de 100644 --- a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md +++ b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md @@ -2,7 +2,7 @@ id: 65824dfdb6815d563b2d3256 title: ステップ 28 challengeType: 20 -dashedName: step-28 +dashedName: step-29 --- # --description-- diff --git a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md index 750a6ebba2a..7fd3f4d7ec7 100644 --- a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md +++ b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md @@ -2,7 +2,7 @@ id: 6582507654b3ed5712341382 title: ステップ 29 challengeType: 20 -dashedName: step-29 +dashedName: step-30 --- # --description-- diff --git a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md index b22271fdc6e..d01b0b91524 100644 --- a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md +++ b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md @@ -2,7 +2,7 @@ id: 658252f6b1526d57b103d48a title: ステップ 30 challengeType: 20 -dashedName: step-30 +dashedName: step-31 --- # --description-- diff --git a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md index 310c2cd9bf9..c5beb83f7c5 100644 --- a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md +++ b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md @@ -2,7 +2,7 @@ id: 658254db6e12485a48130f57 title: ステップ 31 challengeType: 20 -dashedName: step-31 +dashedName: step-32 --- # --description-- diff --git a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md index c99a4db1297..f3898db760d 100644 --- a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md +++ b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md @@ -2,7 +2,7 @@ id: 658255d5f955175b270f251d title: ステップ 32 challengeType: 20 -dashedName: step-32 +dashedName: step-33 --- # --description-- diff --git a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md index 9d187414e4a..120e228d0ec 100644 --- a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md +++ b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md @@ -2,7 +2,7 @@ id: 6582575b8089f85b8b92d7c8 title: ステップ 33 challengeType: 20 -dashedName: step-33 +dashedName: step-34 --- # --description-- diff --git a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md index 81f9d0868e1..e6719423948 100644 --- a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md +++ b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md @@ -2,7 +2,7 @@ id: 658258c0e5fbe85c14c060cf title: ステップ 34 challengeType: 20 -dashedName: step-34 +dashedName: step-35 --- # --description-- diff --git a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md index 89450a773d9..853d5d668b7 100644 --- a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md +++ b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md @@ -2,7 +2,7 @@ id: 65825a9520a0795c8afbef50 title: ステップ 35 challengeType: 20 -dashedName: step-35 +dashedName: step-36 --- # --description-- diff --git a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md index 1531e711127..2ecdbffc6e8 100644 --- a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md +++ b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md @@ -2,7 +2,7 @@ id: 65825b758fe85a5cebabc8c5 title: ステップ 36 challengeType: 20 -dashedName: step-36 +dashedName: step-37 --- # --description-- diff --git a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md index 1d222dc1bc8..20783f47803 100644 --- a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md +++ b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md @@ -2,7 +2,7 @@ id: 65825cda2668995d5168e37c title: ステップ 37 challengeType: 20 -dashedName: step-37 +dashedName: step-38 --- # --description-- diff --git a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md index 0d39924faa1..36e1b5effce 100644 --- a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md +++ b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md @@ -2,7 +2,7 @@ id: 65825e96b5db5f5dee6bf57c title: ステップ 38 challengeType: 20 -dashedName: step-38 +dashedName: step-39 --- # --description-- diff --git a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md index 805aebd65c2..bc207ad4231 100644 --- a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md +++ b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md @@ -2,7 +2,7 @@ id: 6582601b2987045e8e7da994 title: ステップ 39 challengeType: 20 -dashedName: step-39 +dashedName: step-40 --- # --description-- diff --git a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md index ead1ea41186..2b082eb0ef9 100644 --- a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md +++ b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md @@ -2,7 +2,7 @@ id: 6582622cb6c11a5f4c5d79b4 title: ステップ 40 challengeType: 20 -dashedName: step-40 +dashedName: step-41 --- # --description-- diff --git a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md index 85c5c04a638..cefae917dd3 100644 --- a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md +++ b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md @@ -2,7 +2,7 @@ id: 6582687859366a618424d84b title: ステップ 41 challengeType: 20 -dashedName: step-41 +dashedName: step-42 --- # --description-- diff --git a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md index 350e1025e0a..46829312024 100644 --- a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md +++ b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md @@ -2,7 +2,7 @@ id: 65826a6e9d189a623141c726 title: ステップ 42 challengeType: 20 -dashedName: step-42 +dashedName: step-43 --- # --description-- diff --git a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md index 0526a4eaa84..64d9e6b7eb9 100644 --- a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md +++ b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md @@ -2,7 +2,7 @@ id: 65826af5b226a5628aa154b1 title: ステップ 43 challengeType: 20 -dashedName: step-43 +dashedName: step-44 --- # --description-- diff --git a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826befd75db5632bd73df6.md b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826befd75db5632bd73df6.md deleted file mode 100644 index 9cdfa041968..00000000000 --- a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826befd75db5632bd73df6.md +++ /dev/null @@ -1,145 +0,0 @@ ---- -id: 65826befd75db5632bd73df6 -title: ステップ 44 -challengeType: 20 -dashedName: step-44 ---- - -# --description-- - -You can use the `__name__` variable to determine if a Python script is being run as the main program or if it is being imported as a module (code written in another Python file). - -If the value of `__name__` is set to `'__main__'`, it implies that the current script is the main program, and not a module. - -As a final step, create an `if` statement to check if `__name__ == '__main__'`, and move the `main()` call inside this block. - -With that, the expense tracker project is complete! - -# --hints-- - -You should have `if __name__ == '__main__':` in your code. - -```js -assert.match(code,/^if\s+__name__\s*==\s*("|')__main__\1\s*:/m); -``` - -Your `main()` call should be inside the `if` statement. - -```js -assert.match(code, /^if\s+__name__\s*==\s*("|')__main__\1\s*:\s*main\s*\(\s*\)/m); -``` - -# --seed-- - -## --seed-contents-- - -```py -def add_expense(expenses, amount, category): - expenses.append({'amount': amount, 'category': category}) - -def print_expenses(expenses): - for expense in expenses: - print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - -def total_expenses(expenses): - return sum(map(lambda expense: expense['amount'], expenses)) - -def filter_expenses_by_category(expenses, category): - return filter(lambda expense: expense['category'] == category, expenses) - - -def main(): - expenses = [] - while True: - print('\nExpense Tracker') - print('1. Add an expense') - print('2. List all expenses') - print('3. Show total expenses') - print('4. Filter expenses by category') - print('5. Exit') - - choice = input('Enter your choice: ') - - if choice == '1': - amount = float(input('Enter amount: ')) - category = input('Enter category: ') - add_expense(expenses, amount, category) - - elif choice == '2': - print('\nAll Expenses:') - print_expenses(expenses) - - elif choice == '3': - print('\nTotal Expenses: ', total_expenses(expenses)) - - elif choice == '4': - category = input('Enter category to filter: ') - print(f'\nExpenses for {category}:') - expenses_from_category = filter_expenses_by_category(expenses, category) - print_expenses(expenses_from_category) - - elif choice == '5': - print('Exiting the program.') - break - ---fcc-editable-region-- -main() ---fcc-editable-region-- -``` - - -# --solutions-- - -```py -def add_expense(expenses, amount, category): - expenses.append({'amount': amount, 'category': category}) - -def print_expenses(expenses): - for expense in expenses: - print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - -def total_expenses(expenses): - return sum(map(lambda expense: expense['amount'], expenses)) - -def filter_expenses_by_category(expenses, category): - return filter(lambda expense: expense['category'] == category, expenses) - - -def main(): - expenses = [] - while True: - print('\nExpense Tracker') - print('1. Add an expense') - print('2. List all expenses') - print('3. Show total expenses') - print('4. Filter expenses by category') - print('5. Exit') - - choice = input('Enter your choice: ') - - if choice == '1': - amount = float(input('Enter amount: ')) - category = input('Enter category: ') - add_expense(expenses, amount, category) - - elif choice == '2': - print('\nAll Expenses:') - print_expenses(expenses) - - elif choice == '3': - print('\nTotal Expenses: ', total_expenses(expenses)) - - elif choice == '4': - category = input('Enter category to filter: ') - print(f'\nExpenses for {category}:') - expenses_from_category = filter_expenses_by_category(expenses, category) - print_expenses(expenses_from_category) - - elif choice == '5': - print('Exiting the program.') - break - -if __name__ == '__main__': - main() - -``` diff --git a/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/66314f2add0a8b57da5d6d91.md b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/66314f2add0a8b57da5d6d91.md new file mode 100644 index 00000000000..43669da4b07 --- /dev/null +++ b/curriculum/challenges/japanese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/66314f2add0a8b57da5d6d91.md @@ -0,0 +1,43 @@ +--- +id: 66314f2add0a8b57da5d6d91 +title: Step 14 +challengeType: 20 +dashedName: step-14 +--- + +# --description-- + +You should see something like `` printed on the console, which is the string representation of the map object returned by `map()`. + +To obtain a readable output you need to turn the map object into a list. Do it by passing the `map()` call as the argument to the `list()` function. + +# --hints-- + +You should pass the `map()` call as the argument to the `list()` function. + +```js +({ test: () => assert(runPython(`_Node(_code).has_call("print(list(map(test, [2,3,5,8])))")`)) }) +``` + +# --seed-- + +## --seed-contents-- + +```py +def add_expense(expenses, amount, category): + expenses.append({'amount': amount, 'category': category}) + +def print_expenses(expenses): + for expense in expenses: + print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') + +def total_expenses(expenses): + pass + +--fcc-editable-region-- +test = lambda x: x * 2 +print(map(test, [2, 3, 5, 8])) +--fcc-editable-region-- + +expenses = [] +``` diff --git a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md index 3937f502dcd..11b248f024d 100644 --- a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md +++ b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md @@ -2,7 +2,7 @@ id: 658238f7604f154ea9a23e1e title: Step 14 challengeType: 20 -dashedName: step-14 +dashedName: step-15 --- # --description-- diff --git a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md index d5386f3df91..b8b9ce4c902 100644 --- a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md +++ b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md @@ -2,7 +2,7 @@ id: 65823b0167fd894f4a7ea60a title: Step 15 challengeType: 20 -dashedName: step-15 +dashedName: step-16 --- # --description-- diff --git a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md index 1fafe039961..1923fc32955 100644 --- a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md +++ b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md @@ -2,7 +2,7 @@ id: 65823bbbdb4eaa4f9d20a0fb title: Step 16 challengeType: 20 -dashedName: step-16 +dashedName: step-17 --- # --description-- diff --git a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md index 656ff52fc46..d17f8f6571d 100644 --- a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md +++ b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md @@ -2,7 +2,7 @@ id: 65823cfc74aa564ffc460489 title: Step 17 challengeType: 20 -dashedName: step-17 +dashedName: step-18 --- # --description-- diff --git a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md index e19a6ff8af6..8a12ecb23ae 100644 --- a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md +++ b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md @@ -2,7 +2,7 @@ id: 65823dde36392f505a39f7c7 title: Step 18 challengeType: 20 -dashedName: step-18 +dashedName: step-19 --- # --description-- diff --git a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md index 05362025e3b..3144540ac2b 100644 --- a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md +++ b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md @@ -2,7 +2,7 @@ id: 65823e87c9741750a22085a7 title: Step 19 challengeType: 20 -dashedName: step-19 +dashedName: step-20 --- # --description-- diff --git a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md index 758894d8784..82a5f51d884 100644 --- a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md +++ b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md @@ -2,7 +2,7 @@ id: 65823ff0d4b991510fade1a8 title: Step 20 challengeType: 20 -dashedName: step-20 +dashedName: step-21 --- # --description-- diff --git a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md index c8a504c95b7..071bed79f3b 100644 --- a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md +++ b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md @@ -2,7 +2,7 @@ id: 65824111a09164518320088d title: Step 21 challengeType: 20 -dashedName: step-21 +dashedName: step-22 --- # --description-- diff --git a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md index 31bdb26a2b4..3d94f5ef49c 100644 --- a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md +++ b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md @@ -2,7 +2,7 @@ id: 658244fdf4b0265334711664 title: Step 22 challengeType: 20 -dashedName: step-22 +dashedName: step-23 --- # --description-- diff --git a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md index 3209e6c77c5..aca7bea5db4 100644 --- a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md +++ b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md @@ -2,7 +2,7 @@ id: 65824561f3478e5371a33ae5 title: Step 23 challengeType: 20 -dashedName: step-23 +dashedName: step-24 --- # --description-- diff --git a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md index 365e4b886ce..420c8c10649 100644 --- a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md +++ b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md @@ -2,7 +2,7 @@ id: 658246c28575d653d1f89b59 title: Step 24 challengeType: 20 -dashedName: step-24 +dashedName: step-25 --- # --description-- diff --git a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md index 1b258f292ea..6660692abda 100644 --- a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md +++ b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md @@ -2,7 +2,7 @@ id: 65824872894f59546e3084e2 title: Step 25 challengeType: 20 -dashedName: step-25 +dashedName: step-26 --- # --description-- diff --git a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md index 29575b7375a..22d112ba0aa 100644 --- a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md +++ b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md @@ -2,7 +2,7 @@ id: 65824a1b16631c54fa524154 title: Step 26 challengeType: 20 -dashedName: step-26 +dashedName: step-27 --- # --description-- diff --git a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md index 6b2bc6ffaee..7d3995272d7 100644 --- a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md +++ b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md @@ -2,7 +2,7 @@ id: 65824c7b4e2da85597693dcf title: Step 27 challengeType: 20 -dashedName: step-27 +dashedName: step-28 --- # --description-- diff --git a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md index 32fe6ab7e0b..70e4eaa73b7 100644 --- a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md +++ b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md @@ -2,7 +2,7 @@ id: 65824dfdb6815d563b2d3256 title: Step 28 challengeType: 20 -dashedName: step-28 +dashedName: step-29 --- # --description-- diff --git a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md index 0940266004e..31d123637f7 100644 --- a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md +++ b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md @@ -2,7 +2,7 @@ id: 6582507654b3ed5712341382 title: Step 29 challengeType: 20 -dashedName: step-29 +dashedName: step-30 --- # --description-- diff --git a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md index 2b88a233291..76034484647 100644 --- a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md +++ b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md @@ -2,7 +2,7 @@ id: 658252f6b1526d57b103d48a title: Step 30 challengeType: 20 -dashedName: step-30 +dashedName: step-31 --- # --description-- diff --git a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md index fa6407ee8b5..f050318957d 100644 --- a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md +++ b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md @@ -2,7 +2,7 @@ id: 658254db6e12485a48130f57 title: Step 31 challengeType: 20 -dashedName: step-31 +dashedName: step-32 --- # --description-- diff --git a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md index b8b4c7503e1..1daa73cbdfa 100644 --- a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md +++ b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md @@ -2,7 +2,7 @@ id: 658255d5f955175b270f251d title: Step 32 challengeType: 20 -dashedName: step-32 +dashedName: step-33 --- # --description-- diff --git a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md index 15a853b8356..25b4133071c 100644 --- a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md +++ b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md @@ -2,7 +2,7 @@ id: 6582575b8089f85b8b92d7c8 title: Step 33 challengeType: 20 -dashedName: step-33 +dashedName: step-34 --- # --description-- diff --git a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md index 0511583a76a..ef4d026b48e 100644 --- a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md +++ b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md @@ -2,7 +2,7 @@ id: 658258c0e5fbe85c14c060cf title: Step 34 challengeType: 20 -dashedName: step-34 +dashedName: step-35 --- # --description-- diff --git a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md index 8db118990af..d2e7d6f68c5 100644 --- a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md +++ b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md @@ -2,7 +2,7 @@ id: 65825a9520a0795c8afbef50 title: Step 35 challengeType: 20 -dashedName: step-35 +dashedName: step-36 --- # --description-- diff --git a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md index 77331e9840b..0f63dc38941 100644 --- a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md +++ b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md @@ -2,7 +2,7 @@ id: 65825b758fe85a5cebabc8c5 title: Step 36 challengeType: 20 -dashedName: step-36 +dashedName: step-37 --- # --description-- diff --git a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md index a4b1b73d0a5..d9b5f0b584f 100644 --- a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md +++ b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md @@ -2,7 +2,7 @@ id: 65825cda2668995d5168e37c title: Step 37 challengeType: 20 -dashedName: step-37 +dashedName: step-38 --- # --description-- diff --git a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md index e0dc7f00d81..21f0252e891 100644 --- a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md +++ b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md @@ -2,7 +2,7 @@ id: 65825e96b5db5f5dee6bf57c title: Step 38 challengeType: 20 -dashedName: step-38 +dashedName: step-39 --- # --description-- diff --git a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md index 69c26e53bbf..b819b6e2eb4 100644 --- a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md +++ b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md @@ -2,7 +2,7 @@ id: 6582601b2987045e8e7da994 title: Step 39 challengeType: 20 -dashedName: step-39 +dashedName: step-40 --- # --description-- diff --git a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md index b7a76116f30..31febcee910 100644 --- a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md +++ b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md @@ -2,7 +2,7 @@ id: 6582622cb6c11a5f4c5d79b4 title: Step 40 challengeType: 20 -dashedName: step-40 +dashedName: step-41 --- # --description-- diff --git a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md index a7dc82d4f78..b75987c7f31 100644 --- a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md +++ b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md @@ -2,7 +2,7 @@ id: 6582687859366a618424d84b title: Step 41 challengeType: 20 -dashedName: step-41 +dashedName: step-42 --- # --description-- diff --git a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md index ee34b84f93a..40ce7efb61b 100644 --- a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md +++ b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md @@ -2,7 +2,7 @@ id: 65826a6e9d189a623141c726 title: Step 42 challengeType: 20 -dashedName: step-42 +dashedName: step-43 --- # --description-- diff --git a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md index 6dc2b7f17f5..6e91d10faa5 100644 --- a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md +++ b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md @@ -2,7 +2,7 @@ id: 65826af5b226a5628aa154b1 title: Step 43 challengeType: 20 -dashedName: step-43 +dashedName: step-44 --- # --description-- diff --git a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826befd75db5632bd73df6.md b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826befd75db5632bd73df6.md deleted file mode 100644 index c5daf97b54e..00000000000 --- a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826befd75db5632bd73df6.md +++ /dev/null @@ -1,145 +0,0 @@ ---- -id: 65826befd75db5632bd73df6 -title: Step 44 -challengeType: 20 -dashedName: step-44 ---- - -# --description-- - -You can use the `__name__` variable to determine if a Python script is being run as the main program or if it is being imported as a module (code written in another Python file). - -If the value of `__name__` is set to `'__main__'`, it implies that the current script is the main program, and not a module. - -As a final step, create an `if` statement to check if `__name__ == '__main__'`, and move the `main()` call inside this block. - -With that, the expense tracker project is complete! - -# --hints-- - -You should have `if __name__ == '__main__':` in your code. - -```js -assert.match(code,/^if\s+__name__\s*==\s*("|')__main__\1\s*:/m); -``` - -Your `main()` call should be inside the `if` statement. - -```js -assert.match(code, /^if\s+__name__\s*==\s*("|')__main__\1\s*:\s*main\s*\(\s*\)/m); -``` - -# --seed-- - -## --seed-contents-- - -```py -def add_expense(expenses, amount, category): - expenses.append({'amount': amount, 'category': category}) - -def print_expenses(expenses): - for expense in expenses: - print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - -def total_expenses(expenses): - return sum(map(lambda expense: expense['amount'], expenses)) - -def filter_expenses_by_category(expenses, category): - return filter(lambda expense: expense['category'] == category, expenses) - - -def main(): - expenses = [] - while True: - print('\nExpense Tracker') - print('1. Add an expense') - print('2. List all expenses') - print('3. Show total expenses') - print('4. Filter expenses by category') - print('5. Exit') - - choice = input('Enter your choice: ') - - if choice == '1': - amount = float(input('Enter amount: ')) - category = input('Enter category: ') - add_expense(expenses, amount, category) - - elif choice == '2': - print('\nAll Expenses:') - print_expenses(expenses) - - elif choice == '3': - print('\nTotal Expenses: ', total_expenses(expenses)) - - elif choice == '4': - category = input('Enter category to filter: ') - print(f'\nExpenses for {category}:') - expenses_from_category = filter_expenses_by_category(expenses, category) - print_expenses(expenses_from_category) - - elif choice == '5': - print('Exiting the program.') - break - ---fcc-editable-region-- -main() ---fcc-editable-region-- -``` - - -# --solutions-- - -```py -def add_expense(expenses, amount, category): - expenses.append({'amount': amount, 'category': category}) - -def print_expenses(expenses): - for expense in expenses: - print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - -def total_expenses(expenses): - return sum(map(lambda expense: expense['amount'], expenses)) - -def filter_expenses_by_category(expenses, category): - return filter(lambda expense: expense['category'] == category, expenses) - - -def main(): - expenses = [] - while True: - print('\nExpense Tracker') - print('1. Add an expense') - print('2. List all expenses') - print('3. Show total expenses') - print('4. Filter expenses by category') - print('5. Exit') - - choice = input('Enter your choice: ') - - if choice == '1': - amount = float(input('Enter amount: ')) - category = input('Enter category: ') - add_expense(expenses, amount, category) - - elif choice == '2': - print('\nAll Expenses:') - print_expenses(expenses) - - elif choice == '3': - print('\nTotal Expenses: ', total_expenses(expenses)) - - elif choice == '4': - category = input('Enter category to filter: ') - print(f'\nExpenses for {category}:') - expenses_from_category = filter_expenses_by_category(expenses, category) - print_expenses(expenses_from_category) - - elif choice == '5': - print('Exiting the program.') - break - -if __name__ == '__main__': - main() - -``` diff --git a/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/66314f2add0a8b57da5d6d91.md b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/66314f2add0a8b57da5d6d91.md new file mode 100644 index 00000000000..43669da4b07 --- /dev/null +++ b/curriculum/challenges/korean/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/66314f2add0a8b57da5d6d91.md @@ -0,0 +1,43 @@ +--- +id: 66314f2add0a8b57da5d6d91 +title: Step 14 +challengeType: 20 +dashedName: step-14 +--- + +# --description-- + +You should see something like `` printed on the console, which is the string representation of the map object returned by `map()`. + +To obtain a readable output you need to turn the map object into a list. Do it by passing the `map()` call as the argument to the `list()` function. + +# --hints-- + +You should pass the `map()` call as the argument to the `list()` function. + +```js +({ test: () => assert(runPython(`_Node(_code).has_call("print(list(map(test, [2,3,5,8])))")`)) }) +``` + +# --seed-- + +## --seed-contents-- + +```py +def add_expense(expenses, amount, category): + expenses.append({'amount': amount, 'category': category}) + +def print_expenses(expenses): + for expense in expenses: + print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') + +def total_expenses(expenses): + pass + +--fcc-editable-region-- +test = lambda x: x * 2 +print(map(test, [2, 3, 5, 8])) +--fcc-editable-region-- + +expenses = [] +``` diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658212ba98182f3e855e85f9.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658212ba98182f3e855e85f9.md index d2c882e1104..51f05e69ed6 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658212ba98182f3e855e85f9.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658212ba98182f3e855e85f9.md @@ -1,6 +1,6 @@ --- id: 658212ba98182f3e855e85f9 -title: 1° passo +title: Step 1 challengeType: 20 dashedName: step-1 --- @@ -13,7 +13,7 @@ Start by defining a function named `add_expense` that takes three parameters: `e # --hints-- -You should declare a function named `add_expense`. +You should use the `def` keyword to declare a function named `add_expense`. ```js ({ test: () => assert(runPython(` diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65821c1c40ccac44adf38e6b.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65821c1c40ccac44adf38e6b.md index 24036657d8b..f2392be1fac 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65821c1c40ccac44adf38e6b.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65821c1c40ccac44adf38e6b.md @@ -1,19 +1,19 @@ --- id: 65821c1c40ccac44adf38e6b -title: Passo 2 +title: Step 2 challengeType: 20 dashedName: step-2 --- # --description-- -A list in Python is a built-in data type that allows you to store many items in a single data structure. In Python, you create a list by putting items inside square brackets `[]`, with each item separated from the following one by a comma. +A list in Python is a built-in data type that allows you to store many items in a single data structure. In Python, you create a list by putting items inside square brackets (`[]`), with each item separated from the following one by a comma. ```py numbers = [1, 2, 3, 4] ``` -Create an empty list named `expenses`. You will use it to store each of your expenses. +Use a pair of square brackets to create an empty list named `expenses`. You will use it to store each of your expenses. # --hints-- @@ -36,7 +36,7 @@ You should assign an empty list to the `expenses` variable. ```py def add_expense(expenses, amount, category): pass - + --fcc-editable-region-- --fcc-editable-region-- diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65821fcc010c3245718f2a06.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65821fcc010c3245718f2a06.md index 11e291338e2..7f5af99e0a8 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65821fcc010c3245718f2a06.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65821fcc010c3245718f2a06.md @@ -1,27 +1,35 @@ --- id: 65821fcc010c3245718f2a06 -title: Passo 3 +title: Step 3 challengeType: 20 dashedName: step-3 --- # --description-- -The `expenses` parameter of your `add_expense` function will be a list of expenses. You want to be able to add items at the end of your list. For that you can use the `.append()` list method: +The `expenses` parameter of your `add_expense` function will be a list of expenses. You want to be able to add items at the end of your list. For that you'll use the `.append()` list method: ```py my_list = [2, 4, 7] my_list.append(3) ``` -In the example above, after appending `3`, `my_list` would be `[2, 4, 7, 3]`. Replace `pass` with a call to the `.append()` method on the `expenses` list. Don't pass any arguments to `.append()` for now. +In the example above, after appending `3`, `my_list` would be `[2, 4, 7, 3]`. + +Replace `pass` with a call to the `.append()` method on the `expenses` list. Don't pass any arguments to `.append()` for now. # --hints-- You should have `expenses.append()` in your function. ```js -assert.match(code, /^\s+expenses\.append\s*\(\s*\)/m) +({ test: () => assert(runPython(`_Node(_code).find_function("add_expense").has_stmt("expenses.append()")`)) }) +``` + +You should not have `pass` in your function. + +```js +({ test: () => assert.isFalse(runPython(`_Node(_code).find_function("add_expense").has_pass()`)) }) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822308ded1ba4632f66aa3.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822308ded1ba4632f66aa3.md index 479d56c91e6..e89afc026b6 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822308ded1ba4632f66aa3.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822308ded1ba4632f66aa3.md @@ -1,13 +1,13 @@ --- id: 65822308ded1ba4632f66aa3 -title: Passo 4 +title: Step 4 challengeType: 20 dashedName: step-4 --- # --description-- -A dictionary is another built-in data type in Python. A dictionary is a collection of data in the form of *key*-*value* pairs. Dictionaries are defined with curly braces `{}` and they contain key-value pairs separated by commas. Each key is followed by a colon `:` and the value: +A dictionary is another built-in data type in Python. A dictionary is a collection of data in the form of *key*-*value* pairs. Dictionaries are defined with curly braces (`{}`) and they contain key-value pairs separated by commas. Each key is followed by a colon (`:`) and the value: ```py {'amount': 50.0, 'category': 'Food'} @@ -19,10 +19,20 @@ Create a dictionary with a key `'amount'` and value of the `amount` parameter an # --hints-- -You should have `expenses.append({'amount': amount})` in your function. +You should pass a dictionary as the argument to the `.append()` method. ```js -assert.match(code, /^\s+expenses\.append\s*\(\s*\{\s*("|')amount\1\s*:\s*amount\s*\}\s*\)/m) +({ test: () => assert(runPython(` +import ast +node = _Node(_code).find_function("add_expense").find_calls("append")[0].find_call_args() +len(node) == 1 and isinstance(node[0].tree, ast.Dict) +`)) }) +``` + +You should pass `{'amount': amount}` as the argument to the `.append()` method. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("add_expense").has_stmt("expenses.append({'amount': amount})")`)) }) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658225d560369446ece5518b.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658225d560369446ece5518b.md index 82416e2ba01..721a796db68 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658225d560369446ece5518b.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658225d560369446ece5518b.md @@ -1,6 +1,6 @@ --- id: 658225d560369446ece5518b -title: Passo 5 +title: Step 5 challengeType: 20 dashedName: step-5 --- @@ -11,10 +11,20 @@ Add another key-value pair to the dictionary you are appending to the `expense` # --hints-- -You should have `expenses.append({'amount': amount, 'category': category})` in your code. +You should add a second key-value pair to the dictionary you are passing as the argument to the `.append()` method. ```js -assert.match(code, /^\s+expenses\.append\s*\(\s*\{\s*("|')amount\1\s*:\s*amount\s*,\s*("|')category\2\s*:\s*category\s*\}\s*\)/m) +({ test: () => assert(runPython(` +import ast +node = _Node(_code).find_function("add_expense").find_calls("append")[0].find_call_args() +len(node) == 1 and isinstance(node[0].tree, ast.Dict) and len(node[0].tree.keys) == 2 +`)) }) +``` + +You should pass `{'amount': amount, 'category': category}` as the argument to the `.append()` method. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("add_expense").has_stmt("expenses.append({'amount': amount, 'category': category})")`)) }) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582267ef39f5047411c1743.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582267ef39f5047411c1743.md index 0a57c9cb5dd..75485fdd124 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582267ef39f5047411c1743.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582267ef39f5047411c1743.md @@ -1,13 +1,13 @@ --- id: 6582267ef39f5047411c1743 -title: 6° passo +title: Step 6 challengeType: 20 dashedName: step-6 --- # --description-- -Start by defining a function named `print_expenses` that takes one parameter `expenses`. This function will later be used to display each expense in your list. +Next, define a function named `print_expenses` that takes one parameter `expenses`. This function will later be used to display each expense in your list. Fill the body of your new function with a `pass` statement. @@ -41,7 +41,7 @@ Your `print_expenses` function should take a single parameter `expenses`. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + --fcc-editable-region-- --fcc-editable-region-- diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822773f4c60a479ec89f66.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822773f4c60a479ec89f66.md index 2e00d76682d..46a26e45ab9 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822773f4c60a479ec89f66.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822773f4c60a479ec89f66.md @@ -1,6 +1,6 @@ --- id: 65822773f4c60a479ec89f66 -title: 7° passo +title: Step 7 challengeType: 20 dashedName: step-7 --- @@ -11,10 +11,22 @@ Inside the `print_expenses` function, create a `for` loop that iterates over eac # --hints-- -You should have `for expense in expenses:` in your `print_expenses` function. Remember to use `pass` within the loop body. +You should create a `for` loop that iterates over `expenses` in your `print_expenses` function. Remember to use `pass` within the loop body. ```js -({ test: () => assert.match(code, /for\s+expense\s+in\s+expenses\s*:/ ) }) +({ test: () => assert(runPython(`_Node(_code).find_function("print_expenses").find_for_loops()[0].find_for_iter().is_equivalent("expenses")`)) }) +``` + +You should use `expense` as the loop variable. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("print_expenses").find_for_loops()[0].find_for_vars().is_equivalent("expense")`)) }) +``` + +You should have `pass` only inside your loop body. + +```js +({ test: () => assert.isFalse(runPython(`_Node(_code).find_function("print_expenses").has_pass()`)) }) ``` # --seed-- @@ -24,7 +36,7 @@ You should have `for expense in expenses:` in your `print_expenses` function. Re ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + --fcc-editable-region-- def print_expenses(expenses): pass diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822934c8a0454803e3ef12.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822934c8a0454803e3ef12.md index f6e00719047..d8e1f7d2e9f 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822934c8a0454803e3ef12.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822934c8a0454803e3ef12.md @@ -1,6 +1,6 @@ --- id: 65822934c8a0454803e3ef12 -title: 8° passo +title: Step 8 challengeType: 20 dashedName: step-8 --- @@ -9,14 +9,20 @@ dashedName: step-8 Next, you are going to display the details for each expense. -Inside the `for` loop, replace `pass` with a `print()` call and pass it the following f-string: `f'Amount: {expense}, Category: {expense}'`. Leave the placeholders empty for now. +Inside the `for` loop, replace `pass` with a `print()` call and pass it the following f-string: `f'Amount: {expense}, Category: {expense}'`. # --hints-- -You should have `print(f'Amount: {expense}, Category: {expense}')` in your `for` loop. +You should print `f'Amount: {expense}, Category: {expense}'` in your `for` loop. ```js -({ test: () => assert.match(code, /^\s+print\s*\(\s*f("|')Amount: \{\s*expense\s*\}, Category: \{\s*expense\s*\}\1\s*\)/m) }) +({ test: () => assert(runPython(`_Node(_code).find_function("print_expenses").find_for_loops()[0].has_call("print(f'Amount: {expense}, Category: {expense}')")`)) }) +``` + +You should not have `pass` inside your loop body. + +```js +({ test: () => assert.isFalse(runPython(`_Node(_code).find_function("print_expenses").find_for_loops()[0].find_bodies()[0].has_pass()`)) }) ``` # --seed-- @@ -26,7 +32,7 @@ You should have `print(f'Amount: {expense}, Category: {expense}')` in your `for` ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + --fcc-editable-region-- def print_expenses(expenses): for expense in expenses: diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822bd82d708c4895080c35.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822bd82d708c4895080c35.md index 5b89122f3f6..3fa3fb568b9 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822bd82d708c4895080c35.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65822bd82d708c4895080c35.md @@ -1,13 +1,18 @@ --- id: 65822bd82d708c4895080c35 -title: 9° passo +title: Step 9 challengeType: 20 dashedName: step-9 --- # --description-- -You can access values in a dictionary through its keys. You need to use the bracket notation and include the key between the square brackets: +In Python, an important thing to know is that the same type of quote used to define a string cannot be used inside it. For example, the string `'I'm a string!'` is not valid. To use the single quote inside that string you should either: + +- Escape the quote by prepending a backlash to it: `'I\'m a string!'` +- Or use double quotes to define the string: `"I'm a string!"` (preferred). + +You can access values in a dictionary through its keys. You need to use bracket notation and include the key between the square brackets: ```py my_dict = {'amount': 50.0, 'category': 'Food'} @@ -31,7 +36,7 @@ You should pass `f'Amount: {expense["amount"]}, Category: {expense["category"]}' ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + --fcc-editable-region-- def print_expenses(expenses): for expense in expenses: diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823040bdb32949d4c1a96f.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823040bdb32949d4c1a96f.md index c8a9d89cd40..ab3e2f9fc07 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823040bdb32949d4c1a96f.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823040bdb32949d4c1a96f.md @@ -1,13 +1,15 @@ --- id: 65823040bdb32949d4c1a96f -title: Passo 10 +title: Step 10 challengeType: 20 dashedName: step-10 --- # --description-- -You will need a function to calculate the total amount of expenses. Define a function named `total_expenses` that takes one parameter `expenses`. Fill the function body with a `pass` statement for now. +You will need a function to calculate the total amount of expenses. + +Define a function named `total_expenses` that takes one parameter `expenses`. Fill the function body with a `pass` statement for now. # --hints-- @@ -21,7 +23,7 @@ You should define a function named `total_expenses`. }) ``` -Your`total_expenses` function should take a single `expenses` parameter. +Your `total_expenses` function should take a single `expenses` parameter. ```js ({ test: () => assert(runPython(` @@ -39,7 +41,7 @@ Your`total_expenses` function should take a single `expenses` parameter. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582324b5d37fe4b622bc3c0.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582324b5d37fe4b622bc3c0.md index 1eb5766bc19..6e9189ed3f0 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582324b5d37fe4b622bc3c0.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582324b5d37fe4b622bc3c0.md @@ -1,6 +1,6 @@ --- id: 6582324b5d37fe4b622bc3c0 -title: Passo 10 +title: Step 11 challengeType: 20 dashedName: step-11 --- @@ -13,14 +13,22 @@ Lambda functions are brief, anonymous functions in Python, ideal for simple, one lambda x: expr ``` -In the example above, `x` is a parameter to be used in the expression `expr`. Create a `test` variable and assign it a lambda function that takes an `x` parameter and returns `x * 2`. +In the example above, `x` represents a parameter to be used in the expression `expr`, and it acts just like any parameter in a traditional function. `expr` is the expression that gets evaluated and returned when the lambda function is called. + +Create a variable named `test` and assign it a lambda function that takes an `x` parameter and returns `x * 2`. # --hints-- -You should have `test = lambda x: x * 2` in your code. +You should declare a variable named `test`. ```js -({ test: () => assert.match(code,/^test\s*=\s*lambda\s+x\s*:\s*x\s*\*\s*2/m)}) +({ test: () => assert(runPython(`_Node(_code).has_variable("test")`))}) +``` + +You should assign `lambda x: x * 2` to your `test` variable. + +```js +({ test: () => assert(runPython(`_Node(_code).find_variable("test").is_equivalent("test = lambda x: x * 2")`))}) ``` # --seed-- @@ -30,14 +38,14 @@ You should have `test = lambda x: x * 2` in your code. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') def total_expenses(expenses): pass - + --fcc-editable-region-- --fcc-editable-region-- diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582352cbdbcde4d0c4f7b0b.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582352cbdbcde4d0c4f7b0b.md index 0e4f8e3f2df..60685d4ceba 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582352cbdbcde4d0c4f7b0b.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582352cbdbcde4d0c4f7b0b.md @@ -1,6 +1,6 @@ --- id: 6582352cbdbcde4d0c4f7b0b -title: Etapa 12 +title: Step 12 challengeType: 20 dashedName: step-12 --- @@ -26,14 +26,14 @@ You should have `print(test(3))` in your code. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') def total_expenses(expenses): pass - + --fcc-editable-region-- test = lambda x: x * 2 diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823634a308cb4d6bcc5fa6.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823634a308cb4d6bcc5fa6.md index b6593a5efc8..59eb3e3c77b 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823634a308cb4d6bcc5fa6.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823634a308cb4d6bcc5fa6.md @@ -1,6 +1,6 @@ --- id: 65823634a308cb4d6bcc5fa6 -title: Etapa 13 +title: Step 13 challengeType: 20 dashedName: step-13 --- @@ -13,9 +13,11 @@ Lambda functions can be valuably combined with the `map()` function, which execu map(lambda x: x * 2, [1, 2, 3]) ``` +The function to execute is passed as the first argument, and the iterable is passed as the second argument. + The result of the example above would be `[2, 4, 6]`, where each item in the list passed to `map()` has been doubled by the action of the lambda function. -Modify your `print()` call to print the result of calling `map()` with `test` as the first argument, and `[2, 3, 5, 8]` as the second argument. +Modify your `print()` call to print the result of calling `map()` with `test` as the first argument, and `[2, 3, 5, 8]` as the second argument. You won't be able to see a readable output yet. # --hints-- @@ -32,14 +34,14 @@ You should have `print(map(test, [2, 3, 5, 8]))` in your code. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') def total_expenses(expenses): pass - + --fcc-editable-region-- test = lambda x: x * 2 print(test(3)) diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md index 9008e60cb97..d9226ae6d34 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md @@ -1,15 +1,15 @@ --- id: 658238f7604f154ea9a23e1e -title: Passo 14 +title: Step 15 challengeType: 20 -dashedName: step-14 +dashedName: step-15 --- # --description-- The `sum()` function returns the sum of the items in the iterable which is passed as its argument. You are going to use `sum()` together with `map()` and `lambda` functions to get the total amount of expenses. -For now, make a little test and modify your current `print()` call by passing `sum(map(test, [2, 3, 5, 8]))` as the argument. +For now, make a little test and modify your current `print()` call replacing the `list()` call with a call to the `sum()` function passing it the current `map()` call as the argument. # --hints-- @@ -26,17 +26,17 @@ You should print `sum(map(test, [2, 3, 5, 8]))`. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') def total_expenses(expenses): pass - + --fcc-editable-region-- test = lambda x: x * 2 -print(map(test, [2, 3, 5, 8])) +print(list(map(test, [2,3,5,8]))) --fcc-editable-region-- expenses = [] diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md index e7f13761f99..c7358d25594 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md @@ -1,28 +1,22 @@ --- id: 65823b0167fd894f4a7ea60a -title: Passo 15 +title: Step 16 challengeType: 20 -dashedName: step-15 +dashedName: step-16 --- # --description-- -Next, you are going to implement the same logic to the `total_expenses` function. +Next, you are going to implement the same logic within the `total_expenses` function. For now, delete both the `test` function and the `print()` call. # --hints-- -You should delete your `test` variable. +You should delete your `test` variable and the related `print()` call. ```js -({ test: () => assert.notMatch(code, /test\s*=/) }) -``` - -You should delete your `print(sum(map(test, [2, 3, 5, 8])))` call. - -```js -({ test: () => assert.notMatch(code, /print\s*\(\s*sum/) }) +({ test: () => assert.isFalse(runPython(`_Node(_code).has_variable("test")`)) }) ``` # --seed-- @@ -32,14 +26,14 @@ You should delete your `print(sum(map(test, [2, 3, 5, 8])))` call. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') def total_expenses(expenses): pass - + --fcc-editable-region-- test = lambda x: x * 2 print(sum(map(test, [2, 3, 5, 8]))) diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md index cb025732c4f..b056b0bb531 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md @@ -1,27 +1,28 @@ --- id: 65823bbbdb4eaa4f9d20a0fb -title: Passo 16 +title: Step 17 challengeType: 20 -dashedName: step-16 +dashedName: step-17 --- # --description-- -Within your `total_expenses` function, replace `pass` with a `lambda` function. Use `expense` as the parameter and return the value of the `'amount'` key in the `expense` dictionary. +In the `total_expenses` function, you'll now integrate a lambda function. Replace `pass` with a lambda function that has `expense` as its parameter. + +`expense` is expected to be a dictionary, and your lambda function should return the value of the `'amount'` key in the `expense` dictionary. # --hints-- -You should have `lambda expense: expense['amount']` in your `total_expenses` function. +You should create a `lambda` function that uses the parameter `expense` and returns `expense['amount']` in your `total_expenses` function. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "total_expenses"); - const {function_body} = foo; - assert(function_body.match(/^\s+lambda\s+expense\s*:\s*expense\s*\[\s*("|')amount\1\s*\]/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("total_expenses").has_stmt("lambda expense: expense['amount']")`)) }) +``` + +You should not have `pass` in your `total_expenses` function. + +```js +({ test: () => assert.isFalse(runPython(`_Node(_code).find_function("total_expenses").has_pass()`)) }) ``` # --seed-- @@ -31,11 +32,11 @@ You should have `lambda expense: expense['amount']` in your `total_expenses` fun ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + --fcc-editable-region-- def total_expenses(expenses): pass diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md index 78e3edd1930..9c4390b4669 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md @@ -1,8 +1,8 @@ --- id: 65823cfc74aa564ffc460489 -title: Passo 17 +title: Step 18 challengeType: 20 -dashedName: step-17 +dashedName: step-18 --- # --description-- @@ -11,17 +11,22 @@ Now, call `map()` passing your `lambda` function as the first argument and the ` # --hints-- -You should have `map(lambda expense: expense['amount'], expenses)` in your code. +You should call the `map()` function inside the `total_expenses` function. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "total_expenses"); - const {function_body} = foo; - assert(function_body.match(/^\s+map\s*\(\s*lambda\s+expense\s*:\s*expense\s*\[\s*("|')amount\1\s*\]\s*,\s*expenses\s*\)/m)); - } -}) +({ test: () => assert(runPython(`len(_Node(_code).find_function("total_expenses").find_calls("map")) == 1`)) }) +``` + +You should pass your `lambda` function as the first argument to the `map()` call. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("total_expenses").find_calls("map")[0].find_call_args()[0].is_equivalent("lambda expense: expense['amount']")`)) }) +``` + +You should pass the `expenses` list as the second argument to the `map()` call. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("total_expenses").find_calls("map")[0].find_call_args()[1].is_equivalent("expenses")`)) }) ``` # --seed-- @@ -31,11 +36,11 @@ You should have `map(lambda expense: expense['amount'], expenses)` in your code. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + --fcc-editable-region-- def total_expenses(expenses): lambda expense: expense['amount'] diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md index 1b3508db3af..9ff07605fac 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md @@ -1,8 +1,8 @@ --- id: 65823dde36392f505a39f7c7 -title: Passo 18 +title: Step 19 challengeType: 20 -dashedName: step-18 +dashedName: step-19 --- # --description-- @@ -11,17 +11,10 @@ Finally, pass your `map()` call to the `sum()` function to obtain the total expe # --hints-- -You should return `sum(map(lambda expense: expense['amount'], expenses))` from your `total_expenses` function. +You should call the `sum()` function passing it your current `map()` call as the argument and return the result from your `total_expenses` function. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "total_expenses"); - const {function_body} = foo; - assert(function_body.match(/^\s+return\s+sum\s*\(\s*map\s*\(\s*lambda\s+expense\s*:\s*expense\s*\[\s*("|')amount\1\s*\]\s*,\s*expenses\s*\)\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("total_expenses").has_return("sum(map(lambda expense: expense['amount'], expenses))")`)) }) ``` # --seed-- @@ -31,11 +24,11 @@ You should return `sum(map(lambda expense: expense['amount'], expenses))` from y ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + --fcc-editable-region-- def total_expenses(expenses): map(lambda expense: expense['amount'], expenses) diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md index 3d023b63c15..da444c85097 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md @@ -1,8 +1,8 @@ --- id: 65823e87c9741750a22085a7 -title: 19° passo +title: Step 20 challengeType: 20 -dashedName: step-19 +dashedName: step-20 --- # --description-- @@ -39,14 +39,14 @@ Your `filter_expenses_by_category` function should take `expenses` and `category ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + --fcc-editable-region-- --fcc-editable-region-- diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md index 10cadc8e664..92b7c92c01d 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md @@ -1,27 +1,26 @@ --- id: 65823ff0d4b991510fade1a8 -title: 20° passo +title: Step 21 challengeType: 20 -dashedName: step-20 +dashedName: step-21 --- # --description-- -Within the `filter_expenses_by_category` function, replace `pass` with a `lambda` function. Use `expense` as the parameter and return the comparison between the value of the `'category'` key of the `expense` dictionary and `category`. +Within the `filter_expenses_by_category` function, replace `pass` with a `lambda` function. Use `expense` as the parameter and return the comparison between the value of the `'category'` key of the `expense` dictionary and `category` using the equality operator. # --hints-- -You should have `lambda expense: expense['category'] == category` inside the `filter_expenses_by_category` function. +You should create a `lambda` function that uses a parameter named `expense` and returns the expression `expense['category'] == category` inside the `filter_expenses_by_category` function. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "filter_expenses_by_category"); - const {function_body} = foo; - assert(function_body.match(/^\s+lambda\s+expense\s*:\s*expense\s*\[\s*("|')category\1\s*\]\s*==\s*category/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("filter_expenses_by_category").has_stmt("lambda expense: expense['category'] == category")`)) }) +``` + +You should not have `pass` inside the `filter_expenses_by_category` function. + +```js +({ test: () => assert.isFalse(runPython(`_Node(_code).find_function("filter_expenses_by_category").has_pass()`)) }) ``` # --seed-- @@ -31,14 +30,14 @@ You should have `lambda expense: expense['category'] == category` inside the `fi ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + --fcc-editable-region-- def filter_expenses_by_category(expenses, category): pass diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md index fc1da273532..fe47ee9f3f2 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md @@ -1,35 +1,42 @@ --- id: 65824111a09164518320088d -title: Passo 21 +title: Step 22 challengeType: 20 -dashedName: step-21 +dashedName: step-22 --- # --description-- -The `filter()` function allows you to select items from an iterable, such as a list, based on the output of a function: +The `filter()` function allows you to select items from an iterable, such as a list, based on the output of a function: ```py filter(my_function, my_list) ``` -`filter()` returns an iterator in which the elements of `my_list` are included, for which `my_function` returns `True`. An iterator is a special object that enables you to iterate over the elements of a collection, like a list. +`filter()` takes a function as its first argument and an iterable as its second argument. It returns an iterator, which is a special object that enables you to iterate over the elements of a collection, like a list. + +The result of the example above is an iterator containing the elements of `my_list` for which `my_function` returns `True`. Within the `filter_expenses_by_category` function, call `filter()` passing the `lambda` function you wrote in the previous step as the first argument and the `expenses` list as the second argument. # --hints-- -You should have `filter(lambda expense: expense['category'] == category, expenses)` in your `filter_expenses_by_category` function. +You should call `filter()` inside the `filter_expenses_by_category` function. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "filter_expenses_by_category"); - const {function_body} = foo; - assert(function_body.match(/^\s+filter\s*\(\s*lambda\s+expense\s*:\s*expense\s*\[\s*("|')category\1\s*\]\s*==\s*category\s*,\s*expenses\s*\)/m)); - } -}) +({ test: () => assert(runPython(`len(_Node(_code).find_function("filter_expenses_by_category").find_calls("filter")) == 1`)) }) +``` + +You should pass `lambda expense: expense['category'] == category` as the first argument to the `filter()` call. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("filter_expenses_by_category").find_calls("filter")[0].find_call_args()[0].is_equivalent("lambda expense: expense['category'] == category")`)) }) +``` + +You should pass `expenses` as the second argument to the `filter()` call. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("filter_expenses_by_category").find_calls("filter")[0].find_call_args()[1].is_equivalent("expenses")`)) }) ``` # --seed-- @@ -39,14 +46,14 @@ You should have `filter(lambda expense: expense['category'] == category, expense ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + --fcc-editable-region-- def filter_expenses_by_category(expenses, category): lambda expense: expense['category'] == category diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md index 5e55f31793f..99c08f3e7d1 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md @@ -1,8 +1,8 @@ --- id: 658244fdf4b0265334711664 -title: Passo 22 +title: Step 23 challengeType: 20 -dashedName: step-22 +dashedName: step-23 --- # --description-- @@ -14,14 +14,7 @@ Finally, return the result of the `filter()` call. You should return the result of the `filter()` call from your `filter_expenses_by_category` function. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "filter_expenses_by_category"); - const {function_body} = foo; - assert(function_body.match(/^\s+return\s+filter\s*\(\s*lambda\s+expense\s*:\s*expense\s*\[\s*("|')category\1\s*\]\s*==\s*category\s*,\s*expenses\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("filter_expenses_by_category").has_return("filter(lambda expense: expense['category'] == category, expenses)")`)) }) ``` # --seed-- @@ -31,14 +24,14 @@ You should return the result of the `filter()` call from your `filter_expenses_b ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + --fcc-editable-region-- def filter_expenses_by_category(expenses, category): filter(lambda expense: expense['category'] == category, expenses) diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md index a1b31ed3970..a2f8efceb9a 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md @@ -1,8 +1,8 @@ --- id: 65824561f3478e5371a33ae5 -title: Passo 23 +title: Step 24 challengeType: 20 -dashedName: step-23 +dashedName: step-24 --- # --description-- @@ -19,6 +19,8 @@ You should define a function named `main()` without parameters. ({ test: () => assert(runPython(` import inspect inspect.isfunction(main) + sig = str(inspect.signature(main)) + sig == '()' `)) }) ``` @@ -26,12 +28,7 @@ You should define a function named `main()` without parameters. You should move the `expenses` list inside the `main()` function body. ```js -({ test: () => assert(runPython(` - import inspect - sig = str(inspect.signature(main)) - sig == '()' - `)) -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_body().is_equivalent("expenses = []")`)) }) ``` # --seed-- @@ -41,14 +38,14 @@ You should move the `expenses` list inside the `main()` function body. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) --fcc-editable-region-- diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md index 6cad2bd7c6e..5471bb36c92 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md @@ -1,8 +1,8 @@ --- id: 658246c28575d653d1f89b59 -title: Passo 24 +title: Step 25 challengeType: 20 -dashedName: step-24 +dashedName: step-25 --- # --description-- @@ -18,30 +18,16 @@ Below the `expenses` list, create a `while` loop. Use `True` for the condition, # --hints-- -You should have `while True:` in your `main()` function. +You should create a `while` loop using `True` as the condition within your `main()` function. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+while\s+True\s*:/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_conditions()[0].is_equivalent("True")`)) }) ``` -You should have `print('\nExpense Tracker')` in your `while` loop. +You should print `'\nExpense Tracker'` in your `while` loop. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+print\s*\(\s*("|')\\nExpense\s*Tracker\1\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_calls("print")[0].is_equivalent("print('\\\\nExpense Tracker')")`)) }) ``` # --seed-- @@ -51,19 +37,19 @@ You should have `print('\nExpense Tracker')` in your `while` loop. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) --fcc-editable-region-- def main(): expenses = [] - + --fcc-editable-region-- ``` diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md index 7504bbffc66..97d773f5cb8 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md @@ -1,29 +1,26 @@ --- id: 65824872894f59546e3084e2 -title: Passo 25 +title: Step 26 challengeType: 20 -dashedName: step-25 +dashedName: step-26 --- # --description-- -The `while` loop you created in the previous step is an infinite loop that will allow the program to continuously present menu options until the user decides to exit. +The `while` loop you created in the previous step is an infinite loop that will allow the program to continuously present menu options until the user decides to exit. -After the `print()` call, add another one to print the string `'1. Add an expense'`. +After the `print()` call, add another `print()` call to print the string `'1. Add an expense'`. # --hints-- -You should have `print('1. Add an expense')` in your `while` loop. +You should print `'1. Add an expense'` within your `while` loop after the existing `print()` call. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+print\s*\(\s*("|')1\.\sAdd\san\sexpense\1\s*\)/m)); - } -}) +({ test: () => assert(runPython(` +call_lst = _Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_calls("print") +test_lst = ["print('\\\\nExpense Tracker')", "print('1. Add an expense')"] +all(call_lst[n].is_equivalent(i) for n, i in enumerate(test_lst)) +`)) }) ``` # --seed-- @@ -33,14 +30,14 @@ You should have `print('1. Add an expense')` in your `while` loop. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) @@ -49,6 +46,6 @@ def main(): --fcc-editable-region-- while True: print('\nExpense Tracker') - + --fcc-editable-region-- ``` diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md index e920d92ef0a..bee24b42de5 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md @@ -1,8 +1,8 @@ --- id: 65824a1b16631c54fa524154 -title: Passo 26 +title: Step 27 challengeType: 20 -dashedName: step-26 +dashedName: step-27 --- # --description-- @@ -11,17 +11,14 @@ Next, add another `print()` call and pass the string `'2. List all expenses'`. # --hints-- -You should have `print('2. List all expenses')` in your `while` loop. +You should print `'2. List all expenses'` in your `while` loop after the existing `print()` calls. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+print\s*\(\s*("|')2\.\sList\sall\sexpenses\1\s*\)/m)); - } -}) +({ test: () => assert(runPython(` +call_lst = _Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_calls("print") +test_lst = ["print('\\\\nExpense Tracker')", "print('1. Add an expense')", "print('2. List all expenses')"] +all(call_lst[n].is_equivalent(i) for n, i in enumerate(test_lst)) +`)) }) ``` # --seed-- @@ -31,14 +28,14 @@ You should have `print('2. List all expenses')` in your `while` loop. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) @@ -48,6 +45,6 @@ def main(): while True: print('\nExpense Tracker') print('1. Add an expense') - + --fcc-editable-region-- ``` diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md index 57f9e9bc96f..132862fc6fe 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md @@ -1,53 +1,44 @@ --- id: 65824c7b4e2da85597693dcf -title: Passo 27 +title: Step 28 challengeType: 20 -dashedName: step-27 +dashedName: step-28 --- # --description-- -Provide the other menu options by printing the following three strings in your `while` loop: `'3. Show total expenses'`, `'4. Filter expenses by category'`, and `'5. Exit'`. +Provide the other menu options by printing the following three strings in your `while` loop: `'3. Show total expenses'`, `'4. Filter expenses by category'`, and `'5. Exit'`. Keep adding the `print()` calls in order. # --hints-- You should have `print('3. Show total expenses')` in your `while` loop. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+print\s*\(\s*("|')3\.\sShow\stotal\sexpenses\1\s*\)/m)); - } -}) +({ test: () => assert(runPython(` +call_lst = _Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_calls("print") +test_lst = ["print('\\\\nExpense Tracker')", "print('1. Add an expense')", "print('2. List all expenses')", "print('3. Show total expenses')"] +all(call_lst[n].is_equivalent(i) for n, i in enumerate(test_lst)) +`)) }) ``` You should have `print('4. Filter expenses by category')` in your `while` loop. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+print\s*\(\s*("|')4\.\sFilter\sexpenses\sby\scategory\1\s*\)/m)); - } -}) +({ test: () => assert(runPython(` +call_lst = _Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_calls("print") +test_lst = ["print('\\\\nExpense Tracker')", "print('1. Add an expense')", "print('2. List all expenses')", "print('3. Show total expenses')", "print('4. Filter expenses by category')"] +all(call_lst[n].is_equivalent(i) for n, i in enumerate(test_lst)) +`)) }) ``` You should have `print('5. Exit')` in your `while` loop. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+print\s*\(\s*("|')5\.\sExit\1\s*\)/m)); - } -}) +({ test: () => assert(runPython(` +call_lst = _Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_calls("print") +test_lst = ["print('\\\\nExpense Tracker')", "print('1. Add an expense')", "print('2. List all expenses')", "print('3. Show total expenses')", "print('4. Filter expenses by category')", "print('5. Exit')"] +all(call_lst[n].is_equivalent(i) for n, i in enumerate(test_lst)) +`)) }) ``` # --seed-- @@ -57,14 +48,14 @@ You should have `print('5. Exit')` in your `while` loop. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) @@ -75,6 +66,6 @@ def main(): print('\nExpense Tracker') print('1. Add an expense') print('2. List all expenses') - + --fcc-editable-region-- ``` diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md index 19f3273a3b8..392024966fb 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md @@ -1,8 +1,8 @@ --- id: 65824dfdb6815d563b2d3256 -title: Passo 28 +title: Step 29 challengeType: 20 -dashedName: step-28 +dashedName: step-29 --- # --description-- @@ -13,17 +13,18 @@ Inside your `while` loop, call the `input()` function passing the string `'Enter # --hints-- -You should have `choice = input('Enter your choice: ')` in your `while` loop. +You should declare a variable named `choice` within your `while` loop. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+choice\s*=\s*input\s*\(\s*("|')Enter\syour\schoice:\s\1\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].has_variable("choice") +`)) }) +``` + +You should assign the result of the `input()` function, with the string `'Enter your choice: '` as its argument, to your `choice` variable. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_variable("choice").is_equivalent("choice = input('Enter your choice: ')") +`)) }) ``` # --seed-- @@ -33,17 +34,17 @@ You should have `choice = input('Enter your choice: ')` in your `while` loop. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) - + --fcc-editable-region-- def main(): expenses = [] @@ -54,6 +55,6 @@ def main(): print('3. Show total expenses') print('4. Filter expenses by category') print('5. Exit') - + --fcc-editable-region-- ``` diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md index 756969ea3db..240d01654e0 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md @@ -1,8 +1,8 @@ --- id: 6582507654b3ed5712341382 -title: Passo 29 +title: Step 30 challengeType: 20 -dashedName: step-29 +dashedName: step-30 --- # --description-- @@ -15,30 +15,27 @@ Inside the `if` statement body, declare a variable `amount` and assign it an emp # --hints-- -You should have `if choice == '1':` in your `while` loop: +You should create an `if` statement that checks if `choice` is equal to `'1'` in your `while` loop. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+if\s+choice\s*==\s*("|')1\1\s*:/m)); - } -}) +({ test: () => assert(runPython(` +cond = _Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_conditions()[0] +cond.is_equivalent("choice == '1'") or cond.is_equivalent("'1' == choice") +`)) }) ``` -You should have `amount = input()` in your `if` statement body: +You should declare a variable named `amount` in your `if` statement body. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+if\s+choice\s*==\s*("|')1\1\s*:\s*amount\s*=\s*input\s*\(\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[0].has_variable("amount") +`)) }) +``` + +You should assign an empty `input()` call to your `amount` variable. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[0].find_variable("amount").is_equivalent("amount = input()") +`)) }) ``` # --seed-- @@ -48,17 +45,17 @@ You should have `amount = input()` in your `if` statement body: ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) - + --fcc-editable-region-- def main(): expenses = [] @@ -69,7 +66,7 @@ def main(): print('3. Show total expenses') print('4. Filter expenses by category') print('5. Exit') - + choice = input('Enter your choice: ') --fcc-editable-region-- diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md index 4cf5424f519..6d76794bd32 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md @@ -1,8 +1,8 @@ --- id: 658252f6b1526d57b103d48a -title: Passo 30 +title: Step 31 challengeType: 20 -dashedName: step-30 +dashedName: step-31 --- # --description-- @@ -13,17 +13,11 @@ Pass the string `'Enter amount: '` to your empty `input()` call, so you can stor # --hints-- -You should have `amount = input('Enter amount: ')` in your `if` statement. +You should pass `'Enter amount: '` to the `input()` call assigned to the `amount` variable. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+if\s+choice\s*==\s*("|')1\1\s*:\s*amount\s*=\s*input\s*\(\s*("|')Enter amount:\s\2\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[0].find_variable("amount").is_equivalent("amount = input('Enter amount: ')") +`)) }) ``` # --seed-- @@ -33,18 +27,17 @@ You should have `amount = input('Enter amount: ')` in your `if` statement. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) - ---fcc-editable-region-- + def main(): expenses = [] while True: @@ -54,9 +47,9 @@ def main(): print('3. Show total expenses') print('4. Filter expenses by category') print('5. Exit') - + choice = input('Enter your choice: ') - +--fcc-editable-region-- if choice == '1': amount = input() --fcc-editable-region-- diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md index bd45260c728..8818d086821 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md @@ -1,8 +1,8 @@ --- id: 658254db6e12485a48130f57 -title: Passo 31 +title: Step 32 challengeType: 20 -dashedName: step-31 +dashedName: step-32 --- # --description-- @@ -13,17 +13,11 @@ Pass `input('Enter amount: ')` to the `float()` function. # --hints-- -You should have `amount = float(input('Enter amount: '))` in your `if` statement. +You should pass `input('Enter amount: ')` to the `float()` function in the assignment of `amount`. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+if\s+choice\s*==\s*("|')1\1\s*:\s*amount\s*=\s*float\s*\(\s*input\s*\(\s*("|')Enter\samount:\s\2\s*\)\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[0].find_variable("amount").is_equivalent("amount = float(input('Enter amount: '))") +`)) }) ``` # --seed-- @@ -33,17 +27,17 @@ You should have `amount = float(input('Enter amount: '))` in your `if` statement ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) - + --fcc-editable-region-- def main(): expenses = [] @@ -54,9 +48,9 @@ def main(): print('3. Show total expenses') print('4. Filter expenses by category') print('5. Exit') - + choice = input('Enter your choice: ') - + if choice == '1': amount = input('Enter amount: ') --fcc-editable-region-- diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md index c1021f7ccfe..520834f9bfc 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md @@ -1,27 +1,26 @@ --- id: 658255d5f955175b270f251d -title: Passo 32 +title: Step 33 challengeType: 20 -dashedName: step-32 +dashedName: step-33 --- # --description-- -Inside your `if` statement, create a variable `category` to store the expense category. Assign it `input('Enter category: ')`. +Inside your `if` statement, create a variable named `category` to store the expense category. Assign it a call to `input()` and use the `'Enter category: '` as the argument. # --hints-- -You should have `category = input('Enter category: ')` in your `if` statement. +You should declare a variable named `category` in your `if` statement. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+if\s+choice\s*==\s*("|')1\1\s*:\s*amount\s*=\s*float\s*\(\s*input\s*\(\s*("|')Enter\samount:\s\2\s*\)\s*\)\s*category\s*=\s*input\s*\(\s*("|')Enter\scategory:\s\3\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[0].has_variable("category")`)) }) +``` + +You should assign `input('Enter category: ')` to your `category` variable. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[0].find_variable("category").is_equivalent("category = input('Enter category: ')")`)) }) ``` # --seed-- @@ -31,17 +30,17 @@ You should have `category = input('Enter category: ')` in your `if` statement. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) - + def main(): expenses = [] @@ -52,11 +51,11 @@ def main(): print('3. Show total expenses') print('4. Filter expenses by category') print('5. Exit') - + choice = input('Enter your choice: ') --fcc-editable-region-- if choice == '1': amount = float(input('Enter amount: ')) - + --fcc-editable-region-- ``` diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md index e4d3b5b0ec0..2923664b6db 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md @@ -1,15 +1,15 @@ --- id: 6582575b8089f85b8b92d7c8 -title: Passo 33 +title: Step 34 challengeType: 20 -dashedName: step-33 +dashedName: step-34 --- # --description-- -After getting the expense details, you need to call the `add_expense` function to add the new expense to the `expenses` list. +Once you have the expense details, you need to call the `add_expense` function to add the new expense to the `expenses` list. -After getting the `amount` and `category` using `input()`, call the `add_expense` function, passing three arguments: `expenses`, `amount` and `category`. +After getting the `amount` and `category` using `input()`, call the `add_expense` function, passing three arguments: `expenses`, `amount` and `category`. - `expenses` is the empty list created in the main function earlier in this project. - `amount` is the amount of the expense. @@ -17,17 +17,22 @@ After getting the `amount` and `category` using `input()`, call the `add_expense # --hints-- -You should have `add_expense(expenses, amount, category)` in your `if` statement. +You should call the `add_expense()` function within your `if` statement. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+if\s+choice\s*==\s*("|')1\1\s*:\s*amount\s*=\s*float\s*\(\s*input\s*\(\s*("|')Enter\samount:\s\2\s*\)\s*\)\s*category\s*=\s*input\s*\(\s*("|')Enter\scategory:\s\3\s*\)\s*add_expense\s*\(\s*expenses\s*,\s*amount\s*,\s*category\s*\)/m)); - } -}) +({ test: () => assert(runPython(`len(_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[0].find_calls("add_expense")) == 1`)) }) +``` + +You should pass three arguments to your `add_expense()` call: `expenses`, `amount`, and `category`. The order matters. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[0].has_call("add_expense(expenses, amount, category)")`)) }) +``` + +Your `add_expense()` call should come after the assignment of `amount` and `category`. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[0].is_equivalent("amount = float(input('Enter amount: '))\\ncategory = input('Enter category: ')\\nadd_expense(expenses, amount, category)")`)) }) ``` # --seed-- @@ -37,17 +42,17 @@ You should have `add_expense(expenses, amount, category)` in your `if` statement ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) - + def main(): expenses = [] @@ -58,12 +63,12 @@ def main(): print('3. Show total expenses') print('4. Filter expenses by category') print('5. Exit') - + choice = input('Enter your choice: ') --fcc-editable-region-- if choice == '1': amount = float(input('Enter amount: ')) category = input('Enter category: ') - + --fcc-editable-region-- ``` diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md index 58aea54a019..50cb2f6a557 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md @@ -1,42 +1,31 @@ --- id: 658258c0e5fbe85c14c060cf -title: Passo 34 +title: Step 35 challengeType: 20 -dashedName: step-34 +dashedName: step-35 --- # --description-- -To list all expenses, you can use an `elif` statement after an `if` statement. The `elif` checks additional conditions and only works following an `if` statement. +To list all expenses, you can use an `elif` clause after an `if` statement. The `elif` checks additional conditions and only works following an `if` statement. -Create an `elif` statement to check if the user's choice equals the string `2`. Inside the `elif` statement, print the string `'\nAll Expenses:'`. +Create an `elif` clause to check if the user's choice equals the string `'2'`. Inside the `elif` clause, print the string `'\nAll Expenses:'`. # --hints-- -You should have `elif choice == '2':` after your `if` statement. +You should create an `elif` clause that checks that `choice` is equal to `'2'` after your `if` statement. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+elif\s+choice\s*==\s*("|')2\1\s*:/m)); - } -}) +({ test: () => assert(runPython(` +cond = _Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_conditions()[1] +cond.is_equivalent("choice == '2'") or cond.is_equivalent("'2' == choice") +`)) }) ``` -You should have `print('\nAll Expenses:')` inside your `elif` statement. +You should print `'\nAll Expenses:'` inside your `elif` clause. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+elif\s+choice\s*==\s*("|')2\1\s*:\s*print\s*\(\s*("|')\\nAll\sExpenses:\2\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[1].has_call("print('\\\\nAll Expenses:')")`)) }) ``` # --seed-- @@ -46,17 +35,17 @@ You should have `print('\nAll Expenses:')` inside your `elif` statement. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) - + def main(): expenses = [] @@ -67,13 +56,13 @@ def main(): print('3. Show total expenses') print('4. Filter expenses by category') print('5. Exit') - + choice = input('Enter your choice: ') --fcc-editable-region-- if choice == '1': amount = float(input('Enter amount: ')) category = input('Enter category: ') add_expense(expenses, amount, category) - + --fcc-editable-region-- ``` diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md index ff903badfb7..28de93f6f77 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md @@ -1,8 +1,8 @@ --- id: 65825a9520a0795c8afbef50 -title: Passo 35 +title: Step 36 challengeType: 20 -dashedName: step-35 +dashedName: step-36 --- # --description-- @@ -11,17 +11,16 @@ After the `print()` call, call the `print_expenses` function to display all the # --hints-- -You should have `print_expenses(expenses)` in your `elif` statement. +You should call the `print_expenses()` function within your `elif` clause. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+elif\s+choice\s*==\s*("|')2\1\s*:\s*print\s*\(\s*("|')\\nAll\sExpenses:\2\s*\)\s*print\s*_expenses\s*\(\s*expenses\s*\)/m)); - } -}) +({ test: () => assert(runPython(`len(_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[1].find_calls("print_expenses")) == 1`)) }) +``` + +You should pass the `expenses` list as the argument to your `print_expenses()` call. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[1].has_call("print_expenses(expenses)")`)) }) ``` # --seed-- @@ -31,17 +30,17 @@ You should have `print_expenses(expenses)` in your `elif` statement. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) - + def main(): expenses = [] @@ -52,7 +51,7 @@ def main(): print('3. Show total expenses') print('4. Filter expenses by category') print('5. Exit') - + choice = input('Enter your choice: ') if choice == '1': @@ -62,6 +61,6 @@ def main(): --fcc-editable-region-- elif choice == '2': print('\nAll Expenses:') - + --fcc-editable-region-- ``` diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md index 972db9bec45..1322922a208 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md @@ -1,42 +1,31 @@ --- id: 65825b758fe85a5cebabc8c5 -title: Passo 36 +title: Step 37 challengeType: 20 -dashedName: step-36 +dashedName: step-37 --- # --description-- -To show the total expenses, create an `elif` statement that checks if `choice == '3'`. +To show the total expenses, create an `elif` statement that checks if `choice == '3'`. If it's true, it means the user wants to see the total expenses. So call `print()` and pass the string `'\nTotal Expenses: '` as the first argument and `total_expenses(expenses)` as the second argument. # --hints-- -You should have `elif choice == '3':` in your code. +You should create an `elif` clause that checks if `choice == '3'`. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert.match(function_body, /\s+elif\s+choice\s*==\s*("|')3\1\s*:/); - } -}) +({ test: () => assert(runPython(` +cond = _Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_conditions()[2] +cond.is_equivalent("choice == '3'") or cond.is_equivalent("'3' == choice") +`)) }) ``` -You should have `print('\nTotal Expenses: ', total_expenses(expenses))` in your `elif` statement. +You should print `'\nTotal Expenses: ', total_expenses(expenses)` in your new `elif` clause. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+elif\s+choice\s*==\s*("|')3\1\s*:\s*print\s*\(\s*("|')\\nTotal\sExpenses:\s\2\s*,\s*total_expenses\s*\(\s*expenses\s*\)\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[2].has_call("print('\\\\nTotal Expenses: ', total_expenses(expenses))")`)) }) ``` # --seed-- @@ -46,17 +35,17 @@ You should have `print('\nTotal Expenses: ', total_expenses(expenses))` in your ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) - + def main(): expenses = [] @@ -67,7 +56,7 @@ def main(): print('3. Show total expenses') print('4. Filter expenses by category') print('5. Exit') - + choice = input('Enter your choice: ') if choice == '1': @@ -78,6 +67,6 @@ def main(): elif choice == '2': print('\nAll Expenses:') print_expenses(expenses) - + --fcc-editable-region-- ``` diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md index 4177eb92bc7..9436b4f73c1 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md @@ -1,40 +1,35 @@ --- id: 65825cda2668995d5168e37c -title: Passo 37 +title: Step 38 challengeType: 20 -dashedName: step-37 +dashedName: step-38 --- # --description-- -Create another `elif` statement that checks if `choice == '4'`. Inside the new `elif`, create a variable `category` and assign it `input('Enter category to filter: ')` to filter the expense category. +Create another `elif` clause that checks if `choice == '4'`. Inside the new `elif`, create a variable `category` and assign it `input('Enter category to filter: ')` to filter the expense category. # --hints-- -You should have `elif choice == '4':` in your code. +You should create an `elif` clause that checks if `choice == '4'`. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+elif\s+choice\s*==\s*("|')4\1\s*:/m)); - } -}) +({ test: () => assert(runPython(` +cond = _Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_conditions()[3] +cond.is_equivalent("choice == '4'") or cond.is_equivalent("'4' == choice") +`)) }) ``` -You should have `category = input('Enter category to filter: ')` in your new `elif` statement. +You should declared a variable named `category` in your new `elif` clause. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+elif\s+choice\s*==\s*("|')4\1\s*:\s*category\s*=\s*input\s*\(\s*("|')Enter\scategory\sto\sfilter:\s\2\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[3].has_variable("category")`)) }) +``` + +You should assign `input('Enter category to filter: ')` to your `category` variable. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[3].find_variable("category").is_equivalent("category = input('Enter category to filter: ')")`)) }) ``` # --seed-- @@ -44,17 +39,17 @@ You should have `category = input('Enter category to filter: ')` in your new `el ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) - + def main(): expenses = [] @@ -65,7 +60,7 @@ def main(): print('3. Show total expenses') print('4. Filter expenses by category') print('5. Exit') - + choice = input('Enter your choice: ') if choice == '1': @@ -79,6 +74,6 @@ def main(): --fcc-editable-region-- elif choice == '3': print('\nTotal Expenses: ', total_expenses(expenses)) - + --fcc-editable-region-- ``` diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md index a0b101563f1..c771cc30551 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md @@ -1,8 +1,8 @@ --- id: 65825e96b5db5f5dee6bf57c -title: Passo 38 +title: Step 39 challengeType: 20 -dashedName: step-38 +dashedName: step-39 --- # --description-- @@ -11,17 +11,10 @@ After getting the category, print the following f-string `f'\nExpenses for {cate # --hints-- -You should print `f'\nExpenses for {category}:'` inside the `elif` statement. +You should print `f'\nExpenses for {category}:'` after the assignment of `category`. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+elif\s+choice\s*==\s*("|')4\1\s*:\s*category\s*=\s*input\s*\(\s*("|')Enter\scategory\sto\sfilter:\s\2\s*\)\s*print\s*\(\s*f("|')\\nExpenses for \{\s*category\s*\}:\3\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[3].is_equivalent("category = input('Enter category to filter: ')\\nprint(f'\\\\nExpenses for {category}:')")`)) }) ``` # --seed-- @@ -31,17 +24,17 @@ You should print `f'\nExpenses for {category}:'` inside the `elif` statement. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) - + def main(): expenses = [] @@ -52,7 +45,7 @@ def main(): print('3. Show total expenses') print('4. Filter expenses by category') print('5. Exit') - + choice = input('Enter your choice: ') if choice == '1': @@ -69,6 +62,6 @@ def main(): --fcc-editable-region-- elif choice == '4': category = input('Enter category to filter: ') - + --fcc-editable-region-- ``` diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md index b3e3f9c2fd5..5a529fbe4bd 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md @@ -1,8 +1,8 @@ --- id: 6582601b2987045e8e7da994 -title: Passo 39 +title: Step 40 challengeType: 20 -dashedName: step-39 +dashedName: step-40 --- # --description-- @@ -11,17 +11,22 @@ After your `print()` call, you need to filter the expenses and print the filtere # --hints-- -You should have `expenses_from_category = filter_expenses_by_category(expenses, category)` in your `elif` statement. +You should declare a variable named `expenses_from_category` in your `elif` clause. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+elif\s+choice\s*==\s*("|')4\1\s*:\s*category\s*=\s*input\s*\(\s*("|')Enter\scategory\sto\sfilter:\s\2\s*\)\s*print\s*\(\s*f("|')\\nExpenses for \{\s*category\s*\}:\3\s*\)\s*expenses_from_category\s*=\s*filter_expenses_by_category\s*\(\s*expenses\s*,\s*category\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[3].has_variable("expenses_from_category")`)) }) +``` + +You should call `filter_expenses_by_category()` passing `expenses` and `category` as the arguments and assign it to your `expenses_from_category` variable. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[3].find_variable("expenses_from_category").is_equivalent("expenses_from_category = filter_expenses_by_category(expenses, category)")`)) }) +``` + +Your `expenses_from_category` variable should come after the `print()` call. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[3].is_equivalent("category = input('Enter category to filter: ')\\nprint(f'\\\\nExpenses for {category}:')\\nexpenses_from_category = filter_expenses_by_category(expenses, category)")`)) }) ``` # --seed-- @@ -31,17 +36,17 @@ You should have `expenses_from_category = filter_expenses_by_category(expenses, ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) - + def main(): expenses = [] @@ -52,7 +57,7 @@ def main(): print('3. Show total expenses') print('4. Filter expenses by category') print('5. Exit') - + choice = input('Enter your choice: ') if choice == '1': @@ -70,6 +75,6 @@ def main(): elif choice == '4': category = input('Enter category to filter: ') print(f'\nExpenses for {category}:') - + --fcc-editable-region-- ``` diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md index 59b52c3f56d..746e7779537 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md @@ -1,27 +1,26 @@ --- id: 6582622cb6c11a5f4c5d79b4 -title: Passo 40 +title: Step 41 challengeType: 20 -dashedName: step-40 +dashedName: step-41 --- # --description-- -Still within the `elif` statement, pass `expenses_from_category` iterator to a `print_expenses` call. +Still within the `elif` clause, pass the `expenses_from_category` iterator to a `print_expenses` call. # --hints-- -You should have `print_expenses(expenses_from_category)` in your code. +You should call `print_expenses()` passing `expenses_from_category` as the argument in your `elif` clause. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+elif\s+choice\s*==\s*("|')4\1\s*:\s*category\s*=\s*input\s*\(\s*("|')Enter\scategory\sto\sfilter:\s\2\s*\)\s*print\s*\(\s*f("|')\\nExpenses for \{\s*category\s*\}:\3\s*\)\s*expenses_from_category\s*=\s*filter_expenses_by_category\s*\(\s*expenses\s*,\s*category\s*\)\s*print_expenses\s*\(\s*expenses_from_category\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[3].has_call("print_expenses(expenses_from_category)")`)) }) +``` + +Your `print_expenses()` call should come after the `expenses_from_category` variable. + +```js +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[3].is_equivalent("category = input('Enter category to filter: ')\\nprint(f'\\\\nExpenses for {category}:')\\nexpenses_from_category = filter_expenses_by_category(expenses, category)\\nprint_expenses(expenses_from_category)")`)) }) ``` # --seed-- @@ -31,17 +30,17 @@ You should have `print_expenses(expenses_from_category)` in your code. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) - + def main(): expenses = [] @@ -52,7 +51,7 @@ def main(): print('3. Show total expenses') print('4. Filter expenses by category') print('5. Exit') - + choice = input('Enter your choice: ') if choice == '1': @@ -71,6 +70,6 @@ def main(): category = input('Enter category to filter: ') print(f'\nExpenses for {category}:') expenses_from_category = filter_expenses_by_category(expenses, category) - + --fcc-editable-region-- ``` diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md index abfbdb1eb2d..76316b1ba48 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md @@ -1,42 +1,31 @@ --- id: 6582687859366a618424d84b -title: Passo 41 +title: Step 42 challengeType: 20 -dashedName: step-41 +dashedName: step-42 --- # --description-- -To provide a way to exit the program, use another `elif` statement to check if `choice` equals the string `'5'`. +To provide a way to exit the program, use another `elif` clause to check if `choice` equals the string `'5'`. -Inside the new `elif` statement, print the string `'Exiting the program.'` to show that the program is terminating its execution. +Inside the new `elif` clause, print the string `'Exiting the program.'` to show that the program is terminating its execution. # --hints-- -You should have `elif choice == '5':` in your code. +You should create an `elif` clause that checks if `choice == '5'`. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+elif\s+choice\s*==\s*("|')5\1\s*:/m)); - } -}) +({ test: () => assert(runPython(` +cond = _Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_conditions()[4] +cond.is_equivalent("choice == '5'") or cond.is_equivalent("'5' == choice") +`)) }) ``` -You should print `'Exiting the program.'` in your new `elif` statement. +You should print `'Exiting the program.'` in your new `elif` clause. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+elif\s+choice\s*==\s*("|')5\1\s*:\s*print\s*\(\s*("|')Exiting\sthe\sprogram.\2\s*\)/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[4].has_call("print('Exiting the program.')")`)) }) ``` # --seed-- @@ -46,17 +35,17 @@ You should print `'Exiting the program.'` in your new `elif` statement. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) - + def main(): expenses = [] @@ -67,7 +56,7 @@ def main(): print('3. Show total expenses') print('4. Filter expenses by category') print('5. Exit') - + choice = input('Enter your choice: ') if choice == '1': @@ -87,6 +76,6 @@ def main(): print(f'\nExpenses for {category}:') expenses_from_category = filter_expenses_by_category(expenses, category) print_expenses(expenses_from_category) - + --fcc-editable-region-- ``` diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md index bb3e5089213..465c1008e5a 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md @@ -1,27 +1,20 @@ --- id: 65826a6e9d189a623141c726 -title: Passo 42 +title: Step 43 challengeType: 20 -dashedName: step-42 +dashedName: step-43 --- # --description-- -Finally, to stop the execution of the `while` loop, add the `break` statement inside your last `elif` statement. +Finally, to stop the execution of the `while` loop, add the `break` statement inside your last `elif` clause. # --hints-- -You should have a `break` statement inside your last `elif`. +You should have a `break` statement after the `print()` call inside your last `elif` clause. ```js -({ test: () => - { - const transformedCode = code.replace(/\r/g, ""); - const foo = __helpers.python.getDef("\n"+transformedCode, "main"); - const {function_body} = foo; - assert(function_body.match(/^\s+break/m)); - } -}) +({ test: () => assert(runPython(`_Node(_code).find_function("main").find_whiles()[0].find_bodies()[0].find_ifs()[0].find_bodies()[4].is_equivalent("print('Exiting the program.')\\nbreak")`)) }) ``` # --seed-- @@ -31,17 +24,17 @@ You should have a `break` statement inside your last `elif`. ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) - + def main(): expenses = [] @@ -52,7 +45,7 @@ def main(): print('3. Show total expenses') print('4. Filter expenses by category') print('5. Exit') - + choice = input('Enter your choice: ') if choice == '1': @@ -75,6 +68,6 @@ def main(): --fcc-editable-region-- elif choice == '5': print('Exiting the program.') - + --fcc-editable-region-- ``` diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md index a4b4cdf5257..b8403971842 100644 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md @@ -1,13 +1,15 @@ --- id: 65826af5b226a5628aa154b1 -title: Passo 43 +title: Step 44 challengeType: 20 -dashedName: step-43 +dashedName: step-44 --- # --description-- -Finally, call your `main()` function, and try the expense tracker program. +Finally, call your `main()` function, and try the expense tracker program in the console. + +With that, the expense tracker project is complete! # --hints-- @@ -24,17 +26,17 @@ assert.match(code, /^main\s*\(\s*\)/m) ```py def add_expense(expenses, amount, category): expenses.append({'amount': amount, 'category': category}) - + def print_expenses(expenses): for expense in expenses: print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - + def total_expenses(expenses): return sum(map(lambda expense: expense['amount'], expenses)) - + def filter_expenses_by_category(expenses, category): return filter(lambda expense: expense['category'] == category, expenses) - + def main(): expenses = [] @@ -45,7 +47,63 @@ def main(): print('3. Show total expenses') print('4. Filter expenses by category') print('5. Exit') + + choice = input('Enter your choice: ') + if choice == '1': + amount = float(input('Enter amount: ')) + category = input('Enter category: ') + add_expense(expenses, amount, category) + + elif choice == '2': + print('\nAll Expenses:') + print_expenses(expenses) + + elif choice == '3': + print('\nTotal Expenses: ', total_expenses(expenses)) + + elif choice == '4': + category = input('Enter category to filter: ') + print(f'\nExpenses for {category}:') + expenses_from_category = filter_expenses_by_category(expenses, category) + print_expenses(expenses_from_category) + + elif choice == '5': + print('Exiting the program.') + break + +--fcc-editable-region-- + +--fcc-editable-region-- +``` + +# --solutions-- + +```py +def add_expense(expenses, amount, category): + expenses.append({'amount': amount, 'category': category}) + +def print_expenses(expenses): + for expense in expenses: + print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') + +def total_expenses(expenses): + return sum(map(lambda expense: expense['amount'], expenses)) + +def filter_expenses_by_category(expenses, category): + return filter(lambda expense: expense['category'] == category, expenses) + + +def main(): + expenses = [] + while True: + print('\nExpense Tracker') + print('1. Add an expense') + print('2. List all expenses') + print('3. Show total expenses') + print('4. Filter expenses by category') + print('5. Exit') + choice = input('Enter your choice: ') if choice == '1': @@ -70,7 +128,6 @@ def main(): print('Exiting the program.') break ---fcc-editable-region-- +main() ---fcc-editable-region-- ``` diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826befd75db5632bd73df6.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826befd75db5632bd73df6.md deleted file mode 100644 index 85e5e7a9fe7..00000000000 --- a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826befd75db5632bd73df6.md +++ /dev/null @@ -1,145 +0,0 @@ ---- -id: 65826befd75db5632bd73df6 -title: Passo 44 -challengeType: 20 -dashedName: step-44 ---- - -# --description-- - -You can use the `__name__` variable to determine if a Python script is being run as the main program or if it is being imported as a module (code written in another Python file). - -If the value of `__name__` is set to `'__main__'`, it implies that the current script is the main program, and not a module. - -As a final step, create an `if` statement to check if `__name__ == '__main__'`, and move the `main()` call inside this block. - -With that, the expense tracker project is complete! - -# --hints-- - -You should have `if __name__ == '__main__':` in your code. - -```js -assert.match(code,/^if\s+__name__\s*==\s*("|')__main__\1\s*:/m); -``` - -Your `main()` call should be inside the `if` statement. - -```js -assert.match(code, /^if\s+__name__\s*==\s*("|')__main__\1\s*:\s*main\s*\(\s*\)/m); -``` - -# --seed-- - -## --seed-contents-- - -```py -def add_expense(expenses, amount, category): - expenses.append({'amount': amount, 'category': category}) - -def print_expenses(expenses): - for expense in expenses: - print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - -def total_expenses(expenses): - return sum(map(lambda expense: expense['amount'], expenses)) - -def filter_expenses_by_category(expenses, category): - return filter(lambda expense: expense['category'] == category, expenses) - - -def main(): - expenses = [] - while True: - print('\nExpense Tracker') - print('1. Add an expense') - print('2. List all expenses') - print('3. Show total expenses') - print('4. Filter expenses by category') - print('5. Exit') - - choice = input('Enter your choice: ') - - if choice == '1': - amount = float(input('Enter amount: ')) - category = input('Enter category: ') - add_expense(expenses, amount, category) - - elif choice == '2': - print('\nAll Expenses:') - print_expenses(expenses) - - elif choice == '3': - print('\nTotal Expenses: ', total_expenses(expenses)) - - elif choice == '4': - category = input('Enter category to filter: ') - print(f'\nExpenses for {category}:') - expenses_from_category = filter_expenses_by_category(expenses, category) - print_expenses(expenses_from_category) - - elif choice == '5': - print('Exiting the program.') - break - ---fcc-editable-region-- -main() ---fcc-editable-region-- -``` - - -# --solutions-- - -```py -def add_expense(expenses, amount, category): - expenses.append({'amount': amount, 'category': category}) - -def print_expenses(expenses): - for expense in expenses: - print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - -def total_expenses(expenses): - return sum(map(lambda expense: expense['amount'], expenses)) - -def filter_expenses_by_category(expenses, category): - return filter(lambda expense: expense['category'] == category, expenses) - - -def main(): - expenses = [] - while True: - print('\nExpense Tracker') - print('1. Add an expense') - print('2. List all expenses') - print('3. Show total expenses') - print('4. Filter expenses by category') - print('5. Exit') - - choice = input('Enter your choice: ') - - if choice == '1': - amount = float(input('Enter amount: ')) - category = input('Enter category: ') - add_expense(expenses, amount, category) - - elif choice == '2': - print('\nAll Expenses:') - print_expenses(expenses) - - elif choice == '3': - print('\nTotal Expenses: ', total_expenses(expenses)) - - elif choice == '4': - category = input('Enter category to filter: ') - print(f'\nExpenses for {category}:') - expenses_from_category = filter_expenses_by_category(expenses, category) - print_expenses(expenses_from_category) - - elif choice == '5': - print('Exiting the program.') - break - -if __name__ == '__main__': - main() - -``` diff --git a/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/66314f2add0a8b57da5d6d91.md b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/66314f2add0a8b57da5d6d91.md new file mode 100644 index 00000000000..43669da4b07 --- /dev/null +++ b/curriculum/challenges/portuguese/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/66314f2add0a8b57da5d6d91.md @@ -0,0 +1,43 @@ +--- +id: 66314f2add0a8b57da5d6d91 +title: Step 14 +challengeType: 20 +dashedName: step-14 +--- + +# --description-- + +You should see something like `` printed on the console, which is the string representation of the map object returned by `map()`. + +To obtain a readable output you need to turn the map object into a list. Do it by passing the `map()` call as the argument to the `list()` function. + +# --hints-- + +You should pass the `map()` call as the argument to the `list()` function. + +```js +({ test: () => assert(runPython(`_Node(_code).has_call("print(list(map(test, [2,3,5,8])))")`)) }) +``` + +# --seed-- + +## --seed-contents-- + +```py +def add_expense(expenses, amount, category): + expenses.append({'amount': amount, 'category': category}) + +def print_expenses(expenses): + for expense in expenses: + print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') + +def total_expenses(expenses): + pass + +--fcc-editable-region-- +test = lambda x: x * 2 +print(map(test, [2, 3, 5, 8])) +--fcc-editable-region-- + +expenses = [] +``` diff --git a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md index e8a337d16b2..bcd9939daf7 100644 --- a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md +++ b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md @@ -2,7 +2,7 @@ id: 658238f7604f154ea9a23e1e title: Hatua ya 14 challengeType: 20 -dashedName: step-14 +dashedName: step-15 --- # --description-- diff --git a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md index 13988d32d9f..640b91aba4a 100644 --- a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md +++ b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md @@ -2,7 +2,7 @@ id: 65823b0167fd894f4a7ea60a title: Hatua ya 15 challengeType: 20 -dashedName: step-15 +dashedName: step-16 --- # --description-- diff --git a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md index 2a6d7c0523c..ac2e4bcb1ae 100644 --- a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md +++ b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md @@ -2,7 +2,7 @@ id: 65823bbbdb4eaa4f9d20a0fb title: Hatua ya 16 challengeType: 20 -dashedName: step-16 +dashedName: step-17 --- # --description-- diff --git a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md index 352dea8ea1e..d1f109bda2e 100644 --- a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md +++ b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md @@ -2,7 +2,7 @@ id: 65823cfc74aa564ffc460489 title: Hatua ya 17 challengeType: 20 -dashedName: step-17 +dashedName: step-18 --- # --description-- diff --git a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md index 09faa14a656..aa640d4b7e6 100644 --- a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md +++ b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md @@ -2,7 +2,7 @@ id: 65823dde36392f505a39f7c7 title: Hatua ya 18 challengeType: 20 -dashedName: step-18 +dashedName: step-19 --- # --description-- diff --git a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md index 57ab4f3fbae..d15c8417b08 100644 --- a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md +++ b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md @@ -2,7 +2,7 @@ id: 65823e87c9741750a22085a7 title: Hatua ya 19 challengeType: 20 -dashedName: step-19 +dashedName: step-20 --- # --description-- diff --git a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md index b9bc26f2ba5..474569c614e 100644 --- a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md +++ b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md @@ -2,7 +2,7 @@ id: 65823ff0d4b991510fade1a8 title: Hatua ya 20 challengeType: 20 -dashedName: step-20 +dashedName: step-21 --- # --description-- diff --git a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md index 6863112d600..613166ffa61 100644 --- a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md +++ b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md @@ -2,7 +2,7 @@ id: 65824111a09164518320088d title: Hatua ya 21 challengeType: 20 -dashedName: step-21 +dashedName: step-22 --- # --description-- diff --git a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md index 4bfb1b3c0da..ddc019919af 100644 --- a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md +++ b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md @@ -2,7 +2,7 @@ id: 658244fdf4b0265334711664 title: Hatua ya 22 challengeType: 20 -dashedName: step-22 +dashedName: step-23 --- # --description-- diff --git a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md index 702177e48e2..02d900567f3 100644 --- a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md +++ b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md @@ -2,7 +2,7 @@ id: 65824561f3478e5371a33ae5 title: Hatua ya 23 challengeType: 20 -dashedName: step-23 +dashedName: step-24 --- # --description-- diff --git a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md index d0d4b683356..942b77066b7 100644 --- a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md +++ b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md @@ -2,7 +2,7 @@ id: 658246c28575d653d1f89b59 title: Hatua ya 24 challengeType: 20 -dashedName: step-24 +dashedName: step-25 --- # --description-- diff --git a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md index 7b740f1a123..42bcd137f75 100644 --- a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md +++ b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md @@ -2,7 +2,7 @@ id: 65824872894f59546e3084e2 title: Hatua ya 25 challengeType: 20 -dashedName: step-25 +dashedName: step-26 --- # --description-- diff --git a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md index b3d81f773a9..152a0f727ca 100644 --- a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md +++ b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md @@ -2,7 +2,7 @@ id: 65824a1b16631c54fa524154 title: Hatua ya 26 challengeType: 20 -dashedName: step-26 +dashedName: step-27 --- # --description-- diff --git a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md index c7b7d61a41d..66fc75f23c0 100644 --- a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md +++ b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md @@ -2,7 +2,7 @@ id: 65824c7b4e2da85597693dcf title: Hatua ya 27 challengeType: 20 -dashedName: step-27 +dashedName: step-28 --- # --description-- diff --git a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md index 998d0a2f143..726c88944b4 100644 --- a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md +++ b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md @@ -2,7 +2,7 @@ id: 65824dfdb6815d563b2d3256 title: Hatua ya 28 challengeType: 20 -dashedName: step-28 +dashedName: step-29 --- # --description-- diff --git a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md index 3f53491bf22..6013cf72fde 100644 --- a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md +++ b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md @@ -2,7 +2,7 @@ id: 6582507654b3ed5712341382 title: Hatua ya 29 challengeType: 20 -dashedName: step-29 +dashedName: step-30 --- # --description-- diff --git a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md index c822106429e..e0c1bb1da81 100644 --- a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md +++ b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md @@ -2,7 +2,7 @@ id: 658252f6b1526d57b103d48a title: Hatua ya 30 challengeType: 20 -dashedName: step-30 +dashedName: step-31 --- # --description-- diff --git a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md index 40d2914ed78..b53b2862b16 100644 --- a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md +++ b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md @@ -2,7 +2,7 @@ id: 658254db6e12485a48130f57 title: Hatua ya 31 challengeType: 20 -dashedName: step-31 +dashedName: step-32 --- # --description-- diff --git a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md index 09440db5ec1..b459b8634cf 100644 --- a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md +++ b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md @@ -2,7 +2,7 @@ id: 658255d5f955175b270f251d title: Hatua ya 32 challengeType: 20 -dashedName: step-32 +dashedName: step-33 --- # --description-- diff --git a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md index 043d735b0b7..f3685bca692 100644 --- a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md +++ b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md @@ -2,7 +2,7 @@ id: 6582575b8089f85b8b92d7c8 title: Hatua ya 33 challengeType: 20 -dashedName: step-33 +dashedName: step-34 --- # --description-- diff --git a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md index 2d6f8815537..31f2bbebcc1 100644 --- a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md +++ b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md @@ -2,7 +2,7 @@ id: 658258c0e5fbe85c14c060cf title: Hatua ya 34 challengeType: 20 -dashedName: step-34 +dashedName: step-35 --- # --description-- diff --git a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md index a549cc1e011..e277bbca5a9 100644 --- a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md +++ b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md @@ -2,7 +2,7 @@ id: 65825a9520a0795c8afbef50 title: Hatua ya 35 challengeType: 20 -dashedName: step-35 +dashedName: step-36 --- # --description-- diff --git a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md index e0eeb04d387..7cb7fc766dd 100644 --- a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md +++ b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md @@ -2,7 +2,7 @@ id: 65825b758fe85a5cebabc8c5 title: Hatua ya 36 challengeType: 20 -dashedName: step-36 +dashedName: step-37 --- # --description-- diff --git a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md index 335d608fbf4..7de30018568 100644 --- a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md +++ b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md @@ -2,7 +2,7 @@ id: 65825cda2668995d5168e37c title: Hatua ya 37 challengeType: 20 -dashedName: step-37 +dashedName: step-38 --- # --description-- diff --git a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md index 7c49180a83b..ecc11ef750c 100644 --- a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md +++ b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md @@ -2,7 +2,7 @@ id: 65825e96b5db5f5dee6bf57c title: Hatua ya 38 challengeType: 20 -dashedName: step-38 +dashedName: step-39 --- # --description-- diff --git a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md index 7b078faebe2..15752619316 100644 --- a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md +++ b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md @@ -2,7 +2,7 @@ id: 6582601b2987045e8e7da994 title: Hatua ya 39 challengeType: 20 -dashedName: step-39 +dashedName: step-40 --- # --description-- diff --git a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md index dfd8f53d855..e5b89214b57 100644 --- a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md +++ b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md @@ -2,7 +2,7 @@ id: 6582622cb6c11a5f4c5d79b4 title: Hatua ya 40 challengeType: 20 -dashedName: step-40 +dashedName: step-41 --- # --description-- diff --git a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md index eb2cfdf52f8..45c98cac5be 100644 --- a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md +++ b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md @@ -2,7 +2,7 @@ id: 6582687859366a618424d84b title: Hatua ya 41 challengeType: 20 -dashedName: step-41 +dashedName: step-42 --- # --description-- diff --git a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md index ebe8c6b7130..4dd301c323d 100644 --- a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md +++ b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md @@ -2,7 +2,7 @@ id: 65826a6e9d189a623141c726 title: Hatua ya 42 challengeType: 20 -dashedName: step-42 +dashedName: step-43 --- # --description-- diff --git a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md index 2a7999986f3..98803d14f64 100644 --- a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md +++ b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md @@ -2,7 +2,7 @@ id: 65826af5b226a5628aa154b1 title: Hatua ya 43 challengeType: 20 -dashedName: step-43 +dashedName: step-44 --- # --description-- diff --git a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826befd75db5632bd73df6.md b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826befd75db5632bd73df6.md deleted file mode 100644 index ff02674e841..00000000000 --- a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826befd75db5632bd73df6.md +++ /dev/null @@ -1,145 +0,0 @@ ---- -id: 65826befd75db5632bd73df6 -title: Hatua ya 44 -challengeType: 20 -dashedName: step-44 ---- - -# --description-- - -You can use the `__name__` variable to determine if a Python script is being run as the main program or if it is being imported as a module (code written in another Python file). - -If the value of `__name__` is set to `'__main__'`, it implies that the current script is the main program, and not a module. - -As a final step, create an `if` statement to check if `__name__ == '__main__'`, and move the `main()` call inside this block. - -With that, the expense tracker project is complete! - -# --hints-- - -You should have `if __name__ == '__main__':` in your code. - -```js -assert.match(code,/^if\s+__name__\s*==\s*("|')__main__\1\s*:/m); -``` - -Your `main()` call should be inside the `if` statement. - -```js -assert.match(code, /^if\s+__name__\s*==\s*("|')__main__\1\s*:\s*main\s*\(\s*\)/m); -``` - -# --seed-- - -## --seed-contents-- - -```py -def add_expense(expenses, amount, category): - expenses.append({'amount': amount, 'category': category}) - -def print_expenses(expenses): - for expense in expenses: - print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - -def total_expenses(expenses): - return sum(map(lambda expense: expense['amount'], expenses)) - -def filter_expenses_by_category(expenses, category): - return filter(lambda expense: expense['category'] == category, expenses) - - -def main(): - expenses = [] - while True: - print('\nExpense Tracker') - print('1. Add an expense') - print('2. List all expenses') - print('3. Show total expenses') - print('4. Filter expenses by category') - print('5. Exit') - - choice = input('Enter your choice: ') - - if choice == '1': - amount = float(input('Enter amount: ')) - category = input('Enter category: ') - add_expense(expenses, amount, category) - - elif choice == '2': - print('\nAll Expenses:') - print_expenses(expenses) - - elif choice == '3': - print('\nTotal Expenses: ', total_expenses(expenses)) - - elif choice == '4': - category = input('Enter category to filter: ') - print(f'\nExpenses for {category}:') - expenses_from_category = filter_expenses_by_category(expenses, category) - print_expenses(expenses_from_category) - - elif choice == '5': - print('Exiting the program.') - break - ---fcc-editable-region-- -main() ---fcc-editable-region-- -``` - - -# --solutions-- - -```py -def add_expense(expenses, amount, category): - expenses.append({'amount': amount, 'category': category}) - -def print_expenses(expenses): - for expense in expenses: - print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - -def total_expenses(expenses): - return sum(map(lambda expense: expense['amount'], expenses)) - -def filter_expenses_by_category(expenses, category): - return filter(lambda expense: expense['category'] == category, expenses) - - -def main(): - expenses = [] - while True: - print('\nExpense Tracker') - print('1. Add an expense') - print('2. List all expenses') - print('3. Show total expenses') - print('4. Filter expenses by category') - print('5. Exit') - - choice = input('Enter your choice: ') - - if choice == '1': - amount = float(input('Enter amount: ')) - category = input('Enter category: ') - add_expense(expenses, amount, category) - - elif choice == '2': - print('\nAll Expenses:') - print_expenses(expenses) - - elif choice == '3': - print('\nTotal Expenses: ', total_expenses(expenses)) - - elif choice == '4': - category = input('Enter category to filter: ') - print(f'\nExpenses for {category}:') - expenses_from_category = filter_expenses_by_category(expenses, category) - print_expenses(expenses_from_category) - - elif choice == '5': - print('Exiting the program.') - break - -if __name__ == '__main__': - main() - -``` diff --git a/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/66314f2add0a8b57da5d6d91.md b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/66314f2add0a8b57da5d6d91.md new file mode 100644 index 00000000000..43669da4b07 --- /dev/null +++ b/curriculum/challenges/swahili/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/66314f2add0a8b57da5d6d91.md @@ -0,0 +1,43 @@ +--- +id: 66314f2add0a8b57da5d6d91 +title: Step 14 +challengeType: 20 +dashedName: step-14 +--- + +# --description-- + +You should see something like `` printed on the console, which is the string representation of the map object returned by `map()`. + +To obtain a readable output you need to turn the map object into a list. Do it by passing the `map()` call as the argument to the `list()` function. + +# --hints-- + +You should pass the `map()` call as the argument to the `list()` function. + +```js +({ test: () => assert(runPython(`_Node(_code).has_call("print(list(map(test, [2,3,5,8])))")`)) }) +``` + +# --seed-- + +## --seed-contents-- + +```py +def add_expense(expenses, amount, category): + expenses.append({'amount': amount, 'category': category}) + +def print_expenses(expenses): + for expense in expenses: + print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') + +def total_expenses(expenses): + pass + +--fcc-editable-region-- +test = lambda x: x * 2 +print(map(test, [2, 3, 5, 8])) +--fcc-editable-region-- + +expenses = [] +``` diff --git a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md index d7fe4dd4a18..df223c0b2de 100644 --- a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md +++ b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658238f7604f154ea9a23e1e.md @@ -2,7 +2,7 @@ id: 658238f7604f154ea9a23e1e title: Крок 14 challengeType: 20 -dashedName: step-14 +dashedName: step-15 --- # --description-- diff --git a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md index e3652aa12e5..cad4729cb10 100644 --- a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md +++ b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823b0167fd894f4a7ea60a.md @@ -2,7 +2,7 @@ id: 65823b0167fd894f4a7ea60a title: Крок 15 challengeType: 20 -dashedName: step-15 +dashedName: step-16 --- # --description-- diff --git a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md index b3c4324ef84..7e34f9ab162 100644 --- a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md +++ b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823bbbdb4eaa4f9d20a0fb.md @@ -2,7 +2,7 @@ id: 65823bbbdb4eaa4f9d20a0fb title: Крок 16 challengeType: 20 -dashedName: step-16 +dashedName: step-17 --- # --description-- diff --git a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md index dae1df6e067..cc6e7d0685d 100644 --- a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md +++ b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823cfc74aa564ffc460489.md @@ -2,7 +2,7 @@ id: 65823cfc74aa564ffc460489 title: Крок 17 challengeType: 20 -dashedName: step-17 +dashedName: step-18 --- # --description-- diff --git a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md index c16193e7953..28aac9c3a6c 100644 --- a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md +++ b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823dde36392f505a39f7c7.md @@ -2,7 +2,7 @@ id: 65823dde36392f505a39f7c7 title: Крок 18 challengeType: 20 -dashedName: step-18 +dashedName: step-19 --- # --description-- diff --git a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md index 0d277bc798c..0f06c30c190 100644 --- a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md +++ b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823e87c9741750a22085a7.md @@ -2,7 +2,7 @@ id: 65823e87c9741750a22085a7 title: Крок 19 challengeType: 20 -dashedName: step-19 +dashedName: step-20 --- # --description-- diff --git a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md index 2a07c498cf6..f39e00168df 100644 --- a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md +++ b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65823ff0d4b991510fade1a8.md @@ -2,7 +2,7 @@ id: 65823ff0d4b991510fade1a8 title: Крок 20 challengeType: 20 -dashedName: step-20 +dashedName: step-21 --- # --description-- diff --git a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md index 49689e5318b..0a90b3cef7e 100644 --- a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md +++ b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824111a09164518320088d.md @@ -2,7 +2,7 @@ id: 65824111a09164518320088d title: Крок 21 challengeType: 20 -dashedName: step-21 +dashedName: step-22 --- # --description-- diff --git a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md index f4d42923807..7e139de4244 100644 --- a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md +++ b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658244fdf4b0265334711664.md @@ -2,7 +2,7 @@ id: 658244fdf4b0265334711664 title: Крок 22 challengeType: 20 -dashedName: step-22 +dashedName: step-23 --- # --description-- diff --git a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md index a07ee116d89..28f70f18616 100644 --- a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md +++ b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824561f3478e5371a33ae5.md @@ -2,7 +2,7 @@ id: 65824561f3478e5371a33ae5 title: Крок 23 challengeType: 20 -dashedName: step-23 +dashedName: step-24 --- # --description-- diff --git a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md index ffe71825d9b..14d6211deee 100644 --- a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md +++ b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658246c28575d653d1f89b59.md @@ -2,7 +2,7 @@ id: 658246c28575d653d1f89b59 title: Крок 24 challengeType: 20 -dashedName: step-24 +dashedName: step-25 --- # --description-- diff --git a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md index c3e7de67b0b..c54d9718540 100644 --- a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md +++ b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824872894f59546e3084e2.md @@ -2,7 +2,7 @@ id: 65824872894f59546e3084e2 title: Крок 25 challengeType: 20 -dashedName: step-25 +dashedName: step-26 --- # --description-- diff --git a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md index 3cae4a20092..2ded09dffe2 100644 --- a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md +++ b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824a1b16631c54fa524154.md @@ -2,7 +2,7 @@ id: 65824a1b16631c54fa524154 title: Крок 26 challengeType: 20 -dashedName: step-26 +dashedName: step-27 --- # --description-- diff --git a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md index 9d56efaceaf..08eb6c0a0f5 100644 --- a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md +++ b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824c7b4e2da85597693dcf.md @@ -2,7 +2,7 @@ id: 65824c7b4e2da85597693dcf title: Крок 27 challengeType: 20 -dashedName: step-27 +dashedName: step-28 --- # --description-- diff --git a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md index b3acfe28976..6c5a0287fbe 100644 --- a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md +++ b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65824dfdb6815d563b2d3256.md @@ -2,7 +2,7 @@ id: 65824dfdb6815d563b2d3256 title: Крок 28 challengeType: 20 -dashedName: step-28 +dashedName: step-29 --- # --description-- diff --git a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md index 9ccec036516..c2f9df38d6a 100644 --- a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md +++ b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582507654b3ed5712341382.md @@ -2,7 +2,7 @@ id: 6582507654b3ed5712341382 title: Крок 29 challengeType: 20 -dashedName: step-29 +dashedName: step-30 --- # --description-- diff --git a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md index 98a089fa0e4..e10297e9483 100644 --- a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md +++ b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658252f6b1526d57b103d48a.md @@ -2,7 +2,7 @@ id: 658252f6b1526d57b103d48a title: Крок 30 challengeType: 20 -dashedName: step-30 +dashedName: step-31 --- # --description-- diff --git a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md index 19a0b086407..ead52883a2a 100644 --- a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md +++ b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658254db6e12485a48130f57.md @@ -2,7 +2,7 @@ id: 658254db6e12485a48130f57 title: Крок 31 challengeType: 20 -dashedName: step-31 +dashedName: step-32 --- # --description-- diff --git a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md index c6bdc977f25..85d7855442f 100644 --- a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md +++ b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658255d5f955175b270f251d.md @@ -2,7 +2,7 @@ id: 658255d5f955175b270f251d title: Крок 32 challengeType: 20 -dashedName: step-32 +dashedName: step-33 --- # --description-- diff --git a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md index c3a9373c54e..0dd7fa68a93 100644 --- a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md +++ b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582575b8089f85b8b92d7c8.md @@ -2,7 +2,7 @@ id: 6582575b8089f85b8b92d7c8 title: Крок 33 challengeType: 20 -dashedName: step-33 +dashedName: step-34 --- # --description-- diff --git a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md index 611d59cbc81..b0b79983f5f 100644 --- a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md +++ b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/658258c0e5fbe85c14c060cf.md @@ -2,7 +2,7 @@ id: 658258c0e5fbe85c14c060cf title: Крок 34 challengeType: 20 -dashedName: step-34 +dashedName: step-35 --- # --description-- diff --git a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md index 2f6b00cf52e..1b56c2098a1 100644 --- a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md +++ b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825a9520a0795c8afbef50.md @@ -2,7 +2,7 @@ id: 65825a9520a0795c8afbef50 title: Крок 35 challengeType: 20 -dashedName: step-35 +dashedName: step-36 --- # --description-- diff --git a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md index 40b60fbebda..ad714acff3c 100644 --- a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md +++ b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825b758fe85a5cebabc8c5.md @@ -2,7 +2,7 @@ id: 65825b758fe85a5cebabc8c5 title: Крок 36 challengeType: 20 -dashedName: step-36 +dashedName: step-37 --- # --description-- diff --git a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md index 68de7445d6f..ccc16172d97 100644 --- a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md +++ b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825cda2668995d5168e37c.md @@ -2,7 +2,7 @@ id: 65825cda2668995d5168e37c title: Крок 37 challengeType: 20 -dashedName: step-37 +dashedName: step-38 --- # --description-- diff --git a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md index d418332103d..29ad091f09e 100644 --- a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md +++ b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65825e96b5db5f5dee6bf57c.md @@ -2,7 +2,7 @@ id: 65825e96b5db5f5dee6bf57c title: Крок 38 challengeType: 20 -dashedName: step-38 +dashedName: step-39 --- # --description-- diff --git a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md index 53da236099f..f87872edeca 100644 --- a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md +++ b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582601b2987045e8e7da994.md @@ -2,7 +2,7 @@ id: 6582601b2987045e8e7da994 title: Крок 39 challengeType: 20 -dashedName: step-39 +dashedName: step-40 --- # --description-- diff --git a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md index c5b8f51d014..ff5a6b78c16 100644 --- a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md +++ b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582622cb6c11a5f4c5d79b4.md @@ -2,7 +2,7 @@ id: 6582622cb6c11a5f4c5d79b4 title: Крок 40 challengeType: 20 -dashedName: step-40 +dashedName: step-41 --- # --description-- diff --git a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md index 35360b234ab..a98456f4c35 100644 --- a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md +++ b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/6582687859366a618424d84b.md @@ -2,7 +2,7 @@ id: 6582687859366a618424d84b title: Крок 41 challengeType: 20 -dashedName: step-41 +dashedName: step-42 --- # --description-- diff --git a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md index 54c0cfde3a3..8bc0ed1f618 100644 --- a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md +++ b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826a6e9d189a623141c726.md @@ -2,7 +2,7 @@ id: 65826a6e9d189a623141c726 title: Крок 42 challengeType: 20 -dashedName: step-42 +dashedName: step-43 --- # --description-- diff --git a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md index 9104846a11c..497ba03f8f5 100644 --- a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md +++ b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826af5b226a5628aa154b1.md @@ -2,7 +2,7 @@ id: 65826af5b226a5628aa154b1 title: Крок 43 challengeType: 20 -dashedName: step-43 +dashedName: step-44 --- # --description-- diff --git a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826befd75db5632bd73df6.md b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826befd75db5632bd73df6.md deleted file mode 100644 index c65b668c39a..00000000000 --- a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/65826befd75db5632bd73df6.md +++ /dev/null @@ -1,145 +0,0 @@ ---- -id: 65826befd75db5632bd73df6 -title: Крок 44 -challengeType: 20 -dashedName: step-44 ---- - -# --description-- - -Можна використати змінну `__name__`, щоб визначити, чи сценарій Python виконується як головна програма, чи імпортується як модуль (код, написаний в іншому файлі Python). - -Якщо значення `__name__` встановлене на `'__main__'`, то поточний сценарій виконується як головна програма, а не модуль. - -Як останній крок створіть інструкцію `if`, щоб перевірити, чи `__name__ == '__main__'`, та перемістіть виклик `main()` до цього блоку. - -На цьому проєкт зі створення трекеру витрат завершено! - -# --hints-- - -Код повинен містити `if __name__ == '__main__':`. - -```js -assert.match(code,/^if\s+__name__\s*==\s*("|')__main__\1\s*:/m); -``` - -Інструкція `if` повинна містити виклик `main()`. - -```js -assert.match(code, /^if\s+__name__\s*==\s*("|')__main__\1\s*:\s*main\s*\(\s*\)/m); -``` - -# --seed-- - -## --seed-contents-- - -```py -def add_expense(expenses, amount, category): - expenses.append({'amount': amount, 'category': category}) - -def print_expenses(expenses): - for expense in expenses: - print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - -def total_expenses(expenses): - return sum(map(lambda expense: expense['amount'], expenses)) - -def filter_expenses_by_category(expenses, category): - return filter(lambda expense: expense['category'] == category, expenses) - - -def main(): - expenses = [] - while True: - print('\nExpense Tracker') - print('1. Add an expense') - print('2. List all expenses') - print('3. Show total expenses') - print('4. Filter expenses by category') - print('5. Exit') - - choice = input('Enter your choice: ') - - if choice == '1': - amount = float(input('Enter amount: ')) - category = input('Enter category: ') - add_expense(expenses, amount, category) - - elif choice == '2': - print('\nAll Expenses:') - print_expenses(expenses) - - elif choice == '3': - print('\nTotal Expenses: ', total_expenses(expenses)) - - elif choice == '4': - category = input('Enter category to filter: ') - print(f'\nExpenses for {category}:') - expenses_from_category = filter_expenses_by_category(expenses, category) - print_expenses(expenses_from_category) - - elif choice == '5': - print('Exiting the program.') - break - ---fcc-editable-region-- -main() ---fcc-editable-region-- -``` - - -# --solutions-- - -```py -def add_expense(expenses, amount, category): - expenses.append({'amount': amount, 'category': category}) - -def print_expenses(expenses): - for expense in expenses: - print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') - -def total_expenses(expenses): - return sum(map(lambda expense: expense['amount'], expenses)) - -def filter_expenses_by_category(expenses, category): - return filter(lambda expense: expense['category'] == category, expenses) - - -def main(): - expenses = [] - while True: - print('\nExpense Tracker') - print('1. Add an expense') - print('2. List all expenses') - print('3. Show total expenses') - print('4. Filter expenses by category') - print('5. Exit') - - choice = input('Enter your choice: ') - - if choice == '1': - amount = float(input('Enter amount: ')) - category = input('Enter category: ') - add_expense(expenses, amount, category) - - elif choice == '2': - print('\nAll Expenses:') - print_expenses(expenses) - - elif choice == '3': - print('\nTotal Expenses: ', total_expenses(expenses)) - - elif choice == '4': - category = input('Enter category to filter: ') - print(f'\nExpenses for {category}:') - expenses_from_category = filter_expenses_by_category(expenses, category) - print_expenses(expenses_from_category) - - elif choice == '5': - print('Exiting the program.') - break - -if __name__ == '__main__': - main() - -``` diff --git a/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/66314f2add0a8b57da5d6d91.md b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/66314f2add0a8b57da5d6d91.md new file mode 100644 index 00000000000..43669da4b07 --- /dev/null +++ b/curriculum/challenges/ukrainian/07-scientific-computing-with-python/learn-lambda-functions-by-building-an-expense-tracker/66314f2add0a8b57da5d6d91.md @@ -0,0 +1,43 @@ +--- +id: 66314f2add0a8b57da5d6d91 +title: Step 14 +challengeType: 20 +dashedName: step-14 +--- + +# --description-- + +You should see something like `` printed on the console, which is the string representation of the map object returned by `map()`. + +To obtain a readable output you need to turn the map object into a list. Do it by passing the `map()` call as the argument to the `list()` function. + +# --hints-- + +You should pass the `map()` call as the argument to the `list()` function. + +```js +({ test: () => assert(runPython(`_Node(_code).has_call("print(list(map(test, [2,3,5,8])))")`)) }) +``` + +# --seed-- + +## --seed-contents-- + +```py +def add_expense(expenses, amount, category): + expenses.append({'amount': amount, 'category': category}) + +def print_expenses(expenses): + for expense in expenses: + print(f'Amount: {expense["amount"]}, Category: {expense["category"]}') + +def total_expenses(expenses): + pass + +--fcc-editable-region-- +test = lambda x: x * 2 +print(map(test, [2, 3, 5, 8])) +--fcc-editable-region-- + +expenses = [] +```