Skip to content

fix: Feat/add workshop python functions#68279

Open
rustom-yadav wants to merge 3 commits into
freeCodeCamp:mainfrom
rustom-yadav:feat/add-workshop-python-functions
Open

fix: Feat/add workshop python functions#68279
rustom-yadav wants to merge 3 commits into
freeCodeCamp:mainfrom
rustom-yadav:feat/add-workshop-python-functions

Conversation

@rustom-yadav

@rustom-yadav rustom-yadav commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Checklist:

Closes #64627

@rustom-yadav rustom-yadav requested review from a team as code owners June 26, 2026 19:59
@github-actions github-actions Bot added scope: curriculum Lessons, Challenges, Projects and other Curricular Content in curriculum directory. platform: learn UI side of the client application that needs familiarity with React, Gatsby etc. scope: i18n language translation/internationalization. Often combined with language type label labels Jun 26, 2026
@github-actions github-actions Bot changed the title Feat/add workshop python functions fix: Feat/add workshop python functions Jun 26, 2026
@github-actions github-actions Bot added the deprioritized PR reviews are deprioritized; lacks productive input and ignores codebase best practices. label Jun 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Hi there,

Thanks for opening this pull request.

The automated checks found some issues:

Linked Issue: We kindly ask that contributors open an issue before submitting a PR so the change can be discussed and approved before work begins. This helps avoid situations where significant effort goes into something we ultimately cannot merge.

Please open an issue first and allow it to be triaged. Once the issue is open for contribution, you are welcome to update this pull request to reflect the issue consensus. Until then, we will not be able to review your pull request.


Join us in our chat room or our forum if you have any questions or need help with contributing.

@majestic-owl448 majestic-owl448 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please link the issue

also please make sure you are using the AST helpers appropriately, check the documentation for each one again please


# --description--

Welcome to the Python Functions and Scope workshop! We are going to learn about how functions work using a kitchen theme.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please don't use second person, workshops should use "you", not "we" or "us"

@@ -0,0 +1,28 @@
{
"isUpcomingChange": true,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"isUpcomingChange": true,
"isUpcomingChange": false,

"workshop-report-card-printer",
"lecture-introduction-to-python-strings",
"workshop-employee-profile-generator",
"workshop-kitchen-inventory-tracker",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please move below lecture-understanding-functions-and-scope


```js
({
test: () => assert(runPython(`_Node(_code).has_call("take_inventory")`))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

has_call wants the function call, not the function name

```js
({
test: () => assert(
runPython(`_Node(_code).find_assignments("eggs")[-1].is_equivalent("make_fried_egg(eggs)")`)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
runPython(`_Node(_code).find_assignments("eggs")[-1].is_equivalent("make_fried_egg(eggs)")`)
runPython(`_Node(_code).find_assignments("eggs")[-1].is_equivalent("eggs = make_fried_egg(eggs)")`)

```js
({
test: () => assert(
runPython(`_Node(_code).find_function("make_fried_egg")`)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
runPython(`_Node(_code).find_function("make_fried_egg")`)
runPython(`_Node(_code).has_function("make_fried_egg")`)

```js
({
test: () => assert(
runPython(`_Node(_code).find_calls("take_inventory()").length === 2`)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
runPython(`_Node(_code).find_calls("take_inventory()").length === 2`)
runPython(`_Node(_code).find_calls("take_inventory").length == 2`)

find_calls wants the function name

also remember that you are running Python inside runPython, Python does not have ===

Comment on lines +27 to +51
test: () => assert(code.match(/print\(\s*f('|")The kitchen has \{total_items\} total items:\1\s*\)/))
})
```

You should have the print(f'- {eggs} eggs') statement inside your function.

```js
({
test: () => assert(code.match(/print\(\s*f('|")-\s\{eggs\}\seggs\1\s*\)/))
})
```

You should have the print(f'- {flour} flour') statement inside your function.

```js
({
test: () => assert(code.match(/print\(\s*f('|")-\s\{flour\}\sflour\1\s*\)/))
})
```

You should have the print(f'- {sugar} sugar') statement inside your function.

```js
({
test: () => assert(code.match(/print\(\s*f('|")-\s\{sugar\}\ssugar\1\s*\)/))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you are not using runPython, remove the test structure here, but it's preferable you test with the AST helpers even this

@majestic-owl448 majestic-owl448 added the status: waiting update Is awaiting update, after feedback or request for changes label Jun 27, 2026
@github-actions github-actions Bot added Naomi's Sprints This label is for issues that Naomi is managing through her sprint initiatives on Discord. and removed deprioritized PR reviews are deprioritized; lacks productive input and ignores codebase best practices. labels Jun 27, 2026
```js
({
test: () => assert(
runPython(`_Node(_code).find_function("take_inventory")`)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
runPython(`_Node(_code).find_function("take_inventory")`)
runPython(`_Node(_code).has_function("take_inventory")`)

the has_ method returns a boolean, please use them in these cases

({
test: () => assert(
runPython(`
_Node(_code).find_function("take_inventory").find_assignments("total_items")[0].is_equivalent("eggs + flour + sugar")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_Node(_code).find_function("take_inventory").find_assignments("total_items")[0].is_equivalent("eggs + flour + sugar")
variable = _Node(_code).find_function("take_inventory").find_variable("total_items")
variable.is_equivalent("total_items = eggs + flour + sugar") or variable.is_equivalent("total_items = eggs + sugar + flour") or ...

please make sure all 6 permutations are allowed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Naomi's Sprints This label is for issues that Naomi is managing through her sprint initiatives on Discord. platform: learn UI side of the client application that needs familiarity with React, Gatsby etc. scope: curriculum Lessons, Challenges, Projects and other Curricular Content in curriculum directory. scope: i18n language translation/internationalization. Often combined with language type label status: waiting update Is awaiting update, after feedback or request for changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create a prototype for Python functions workshop

2 participants