fix(curriculum/python): improve shortest path algorithm project (#53428)

Co-authored-by: Ilenia <26656284+ilenia-magoni@users.noreply.github.com>
This commit is contained in:
Dario-DC
2024-05-21 16:36:53 +02:00
committed by GitHub
parent 9d7880bea0
commit 8d638df973
635 changed files with 4800 additions and 1569 deletions
@@ -43,188 +43,208 @@
"title": "Step 8"
},
{
"id": "6579cbab9825b8170974c69a",
"id": "65b7cd2b7bd9a684ccf1dc16",
"title": "Step 9"
},
{
"id": "6579cd5f6dd62c189e53ddbb",
"id": "65b7cf140d34058d7ea8935f",
"title": "Step 10"
},
{
"id": "6579dd49fa8a8e1fd06b85a9",
"id": "65b7d25992879698180e6a71",
"title": "Step 11"
},
{
"id": "6557709b0aee699a6a00528c",
"id": "65b7d3319ebec69b983fb91b",
"title": "Step 12"
},
{
"id": "6557712d77ce2d9bd7e63afd",
"id": "6579cbab9825b8170974c69a",
"title": "Step 13"
},
{
"id": "6557716aadbd2d9c42c0e69a",
"id": "6579cd5f6dd62c189e53ddbb",
"title": "Step 14"
},
{
"id": "655771d889132f9ccd341060",
"id": "6579dd49fa8a8e1fd06b85a9",
"title": "Step 15"
},
{
"id": "6566195b0a021bb660b2b4b1",
"id": "6557709b0aee699a6a00528c",
"title": "Step 16"
},
{
"id": "65661b72d6745ebec6a96923",
"id": "65affe602a2a828b0382a058",
"title": "Step 17"
},
{
"id": "65577236b056379d5dbc7000",
"id": "6557712d77ce2d9bd7e63afd",
"title": "Step 18"
},
{
"id": "655773b0591c5f9f4045883e",
"id": "6557716aadbd2d9c42c0e69a",
"title": "Step 19"
},
{
"id": "655773f8b8b5db9fc6d0ae76",
"id": "655771d889132f9ccd341060",
"title": "Step 20"
},
{
"id": "6557743527cb92a06417ea97",
"id": "6566195b0a021bb660b2b4b1",
"title": "Step 21"
},
{
"id": "6557746aad2844a0cd864e12",
"id": "65661b72d6745ebec6a96923",
"title": "Step 22"
},
{
"id": "655774955b097ea14897db12",
"id": "65577236b056379d5dbc7000",
"title": "Step 23"
},
{
"id": "655774d01daeeaa1978b99d5",
"id": "655773b0591c5f9f4045883e",
"title": "Step 24"
},
{
"id": "655775221059f5a20493d5d7",
"id": "655773f8b8b5db9fc6d0ae76",
"title": "Step 25"
},
{
"id": "655776db1eeae0a620e42a0d",
"id": "6557743527cb92a06417ea97",
"title": "Step 26"
},
{
"id": "655777060d8ddea6741be1b1",
"id": "6557746aad2844a0cd864e12",
"title": "Step 27"
},
{
"id": "65577739f57ecca6c39bb4e9",
"id": "655774955b097ea14897db12",
"title": "Step 28"
},
{
"id": "65577791ad8c26a7705e2919",
"id": "655774d01daeeaa1978b99d5",
"title": "Step 29"
},
{
"id": "65577a17564ce8a8e06c1460",
"id": "655775221059f5a20493d5d7",
"title": "Step 30"
},
{
"id": "65578c17d54dfab65cd54b95",
"id": "655776db1eeae0a620e42a0d",
"title": "Step 31"
},
{
"id": "65578c74607d40b6d8c4757f",
"id": "655777060d8ddea6741be1b1",
"title": "Step 32"
},
{
"id": "65578cb031cd93b77a285db2",
"id": "65577739f57ecca6c39bb4e9",
"title": "Step 33"
},
{
"id": "65578cee7f2cb8b80127cce2",
"id": "65577791ad8c26a7705e2919",
"title": "Step 34"
},
{
"id": "65578d0f6c78a0b868a43b9c",
"id": "65577a17564ce8a8e06c1460",
"title": "Step 35"
},
{
"id": "65578d4fc3afc3b8f554c882",
"id": "65578c17d54dfab65cd54b95",
"title": "Step 36"
},
{
"id": "65578f895f2a65ba7a916804",
"id": "65578c74607d40b6d8c4757f",
"title": "Step 37"
},
{
"id": "65578fcf00322dbad5dee05b",
"id": "65578cb031cd93b77a285db2",
"title": "Step 38"
},
{
"id": "657891ab9c1903f4e55433ba",
"id": "65578cee7f2cb8b80127cce2",
"title": "Step 39"
},
{
"id": "655790d113d14dbb727eaf41",
"id": "65578d0f6c78a0b868a43b9c",
"title": "Step 40"
},
{
"id": "6557910b0ebaeebc18209e90",
"id": "65578d4fc3afc3b8f554c882",
"title": "Step 41"
},
{
"id": "6557913b8fe5c0bc834c9f4f",
"id": "65578f895f2a65ba7a916804",
"title": "Step 42"
},
{
"id": "655791847db8a9bd0b685f40",
"id": "65578fcf00322dbad5dee05b",
"title": "Step 43"
},
{
"id": "655791ae44c182bd92f31caa",
"id": "657891ab9c1903f4e55433ba",
"title": "Step 44"
},
{
"id": "655791e6cf5e03be3de73451",
"id": "655790d113d14dbb727eaf41",
"title": "Step 45"
},
{
"id": "6567722f53ad97d7ea6bb082",
"id": "6557910b0ebaeebc18209e90",
"title": "Step 46"
},
{
"id": "65579228c669fcbebffd01d5",
"id": "6557913b8fe5c0bc834c9f4f",
"title": "Step 47"
},
{
"id": "6557924d47c325bf27afbe51",
"id": "655791847db8a9bd0b685f40",
"title": "Step 48"
},
{
"id": "6559d70c5161b16ff1d6530d",
"id": "655791ae44c182bd92f31caa",
"title": "Step 49"
},
{
"id": "6557927ad11e58bf8c794b25",
"id": "655791e6cf5e03be3de73451",
"title": "Step 50"
},
{
"id": "6559d86fe1b8947954b9178d",
"id": "6567722f53ad97d7ea6bb082",
"title": "Step 51"
},
{
"id": "6559da1b7d75f088f5e6b89f",
"id": "65579228c669fcbebffd01d5",
"title": "Step 52"
},
{
"id": "65774ae7c3eee66fe79b9459",
"id": "6557924d47c325bf27afbe51",
"title": "Step 53"
},
{
"id": "6559da93115de78dbbdc7ba3",
"id": "6559d70c5161b16ff1d6530d",
"title": "Step 54"
},
{
"id": "6557927ad11e58bf8c794b25",
"title": "Step 55"
},
{
"id": "6559d86fe1b8947954b9178d",
"title": "Step 56"
},
{
"id": "6559da1b7d75f088f5e6b89f",
"title": "Step 57"
},
{
"id": "65774ae7c3eee66fe79b9459",
"title": "Step 58"
},
{
"id": "6559da93115de78dbbdc7ba3",
"title": "Step 59"
}
],
"helpCategory": "Python"
@@ -2,7 +2,7 @@
id: 6557709b0aee699a6a00528c
title: الخطوة 12
challengeType: 20
dashedName: step-12
dashedName: step-16
---
# --description--
@@ -2,7 +2,7 @@
id: 6557712d77ce2d9bd7e63afd
title: الخطوة 13
challengeType: 20
dashedName: step-13
dashedName: step-18
---
# --description--
@@ -2,7 +2,7 @@
id: 6557716aadbd2d9c42c0e69a
title: الخطوة 14
challengeType: 20
dashedName: step-14
dashedName: step-19
---
# --description--
@@ -2,7 +2,7 @@
id: 655771d889132f9ccd341060
title: الخطوة 15
challengeType: 20
dashedName: step-15
dashedName: step-20
---
# --description--
@@ -2,7 +2,7 @@
id: 65577236b056379d5dbc7000
title: الخطوة 18
challengeType: 20
dashedName: step-18
dashedName: step-23
---
# --description--
@@ -2,7 +2,7 @@
id: 655773b0591c5f9f4045883e
title: الخطوة 19
challengeType: 20
dashedName: step-19
dashedName: step-24
---
# --description--
@@ -2,7 +2,7 @@
id: 655773f8b8b5db9fc6d0ae76
title: الخطوة 20
challengeType: 20
dashedName: step-20
dashedName: step-25
---
# --description--
@@ -2,7 +2,7 @@
id: 6557743527cb92a06417ea97
title: الخطوة 21
challengeType: 20
dashedName: step-21
dashedName: step-26
---
# --description--
@@ -2,7 +2,7 @@
id: 6557746aad2844a0cd864e12
title: الخطوة 22
challengeType: 20
dashedName: step-22
dashedName: step-27
---
# --description--
@@ -2,7 +2,7 @@
id: 655774955b097ea14897db12
title: الخطوة 23
challengeType: 20
dashedName: step-23
dashedName: step-28
---
# --description--
@@ -2,7 +2,7 @@
id: 655774d01daeeaa1978b99d5
title: الخطوة 24
challengeType: 20
dashedName: step-24
dashedName: step-29
---
# --description--
@@ -2,7 +2,7 @@
id: 655775221059f5a20493d5d7
title: الخطوة 25
challengeType: 20
dashedName: step-25
dashedName: step-30
---
# --description--
@@ -2,7 +2,7 @@
id: 655776db1eeae0a620e42a0d
title: الخطوة 26
challengeType: 20
dashedName: step-26
dashedName: step-31
---
# --description--
@@ -2,7 +2,7 @@
id: 655777060d8ddea6741be1b1
title: الخطوة 27
challengeType: 20
dashedName: step-27
dashedName: step-32
---
# --description--
@@ -2,7 +2,7 @@
id: 65577739f57ecca6c39bb4e9
title: الخطوة 28
challengeType: 20
dashedName: step-28
dashedName: step-33
---
# --description--
@@ -2,7 +2,7 @@
id: 65577791ad8c26a7705e2919
title: الخطوة 29
challengeType: 20
dashedName: step-29
dashedName: step-34
---
# --description--
@@ -2,7 +2,7 @@
id: 65577a17564ce8a8e06c1460
title: الخطوة 30
challengeType: 20
dashedName: step-30
dashedName: step-35
---
# --description--
@@ -2,7 +2,7 @@
id: 65578c17d54dfab65cd54b95
title: الخطوة 31
challengeType: 20
dashedName: step-31
dashedName: step-36
---
# --description--
@@ -2,7 +2,7 @@
id: 65578c74607d40b6d8c4757f
title: الخطوة 32
challengeType: 20
dashedName: step-32
dashedName: step-37
---
# --description--
@@ -2,7 +2,7 @@
id: 65578cb031cd93b77a285db2
title: الخطوة 33
challengeType: 20
dashedName: step-33
dashedName: step-38
---
# --description--
@@ -2,7 +2,7 @@
id: 65578cee7f2cb8b80127cce2
title: الخطوة 34
challengeType: 20
dashedName: step-34
dashedName: step-39
---
# --description--
@@ -2,7 +2,7 @@
id: 65578d0f6c78a0b868a43b9c
title: الخطوة 35
challengeType: 20
dashedName: step-35
dashedName: step-40
---
# --description--
@@ -2,7 +2,7 @@
id: 65578d4fc3afc3b8f554c882
title: الخطوة 36
challengeType: 20
dashedName: step-36
dashedName: step-41
---
# --description--
@@ -2,7 +2,7 @@
id: 65578f895f2a65ba7a916804
title: الخطوة 37
challengeType: 20
dashedName: step-37
dashedName: step-42
---
# --description--
@@ -2,7 +2,7 @@
id: 65578fcf00322dbad5dee05b
title: الخطوة 38
challengeType: 20
dashedName: step-38
dashedName: step-43
---
# --description--
@@ -2,7 +2,7 @@
id: 655790d113d14dbb727eaf41
title: الخطوة 40
challengeType: 20
dashedName: step-40
dashedName: step-45
---
# --description--
@@ -2,7 +2,7 @@
id: 6557910b0ebaeebc18209e90
title: الخطوة 41
challengeType: 20
dashedName: step-41
dashedName: step-46
---
# --description--
@@ -2,7 +2,7 @@
id: 6557913b8fe5c0bc834c9f4f
title: الخطوة 42
challengeType: 20
dashedName: step-42
dashedName: step-47
---
# --description--
@@ -2,7 +2,7 @@
id: 655791847db8a9bd0b685f40
title: الخطوة 43
challengeType: 20
dashedName: step-43
dashedName: step-48
---
# --description--
@@ -2,7 +2,7 @@
id: 655791ae44c182bd92f31caa
title: الخطوة 44
challengeType: 20
dashedName: step-44
dashedName: step-49
---
# --description--
@@ -2,7 +2,7 @@
id: 655791e6cf5e03be3de73451
title: الخطوة 45
challengeType: 20
dashedName: step-45
dashedName: step-50
---
# --description--
@@ -2,7 +2,7 @@
id: 65579228c669fcbebffd01d5
title: الخطوة 47
challengeType: 20
dashedName: step-47
dashedName: step-52
---
# --description--
@@ -2,7 +2,7 @@
id: 6557924d47c325bf27afbe51
title: الخطوة 48
challengeType: 20
dashedName: step-48
dashedName: step-53
---
# --description--
@@ -2,7 +2,7 @@
id: 6557927ad11e58bf8c794b25
title: الخطوة 50
challengeType: 20
dashedName: step-50
dashedName: step-55
---
# --description--
@@ -2,7 +2,7 @@
id: 6559d70c5161b16ff1d6530d
title: الخطوة 49
challengeType: 20
dashedName: step-49
dashedName: step-54
---
# --description--
@@ -2,7 +2,7 @@
id: 6559d86fe1b8947954b9178d
title: الخطوة 51
challengeType: 20
dashedName: step-51
dashedName: step-56
---
# --description--
@@ -2,7 +2,7 @@
id: 6559da1b7d75f088f5e6b89f
title: الخطوة 52
challengeType: 20
dashedName: step-52
dashedName: step-57
---
# --description--
@@ -2,7 +2,7 @@
id: 6559da93115de78dbbdc7ba3
title: الخطوة 54
challengeType: 20
dashedName: step-54
dashedName: step-59
---
# --description--
@@ -2,7 +2,7 @@
id: 6566195b0a021bb660b2b4b1
title: الخطوة 16
challengeType: 20
dashedName: step-16
dashedName: step-21
---
# --description--
@@ -2,7 +2,7 @@
id: 65661b72d6745ebec6a96923
title: الخطوة 17
challengeType: 20
dashedName: step-17
dashedName: step-22
---
# --description--
@@ -2,7 +2,7 @@
id: 6567722f53ad97d7ea6bb082
title: الخطوة 46
challengeType: 20
dashedName: step-46
dashedName: step-51
---
# --description--
@@ -2,7 +2,7 @@
id: 65774ae7c3eee66fe79b9459
title: الخطوة 53
challengeType: 20
dashedName: step-53
dashedName: step-58
---
# --description--
@@ -2,7 +2,7 @@
id: 657891ab9c1903f4e55433ba
title: الخطوة 39
challengeType: 20
dashedName: step-39
dashedName: step-44
---
# --description--
@@ -2,7 +2,7 @@
id: 6579cbab9825b8170974c69a
title: الخطوة 9
challengeType: 20
dashedName: step-9
dashedName: step-13
---
# --description--
@@ -2,7 +2,7 @@
id: 6579cd5f6dd62c189e53ddbb
title: الخطوة 10
challengeType: 20
dashedName: step-10
dashedName: step-14
---
# --description--
@@ -2,7 +2,7 @@
id: 6579dd49fa8a8e1fd06b85a9
title: الخطوة 11
challengeType: 20
dashedName: step-11
dashedName: step-15
---
# --description--
@@ -0,0 +1,75 @@
---
id: 65affe602a2a828b0382a058
title: Step 17
challengeType: 20
dashedName: step-17
---
# --description--
Replace the `'age'` key with the string `'B'` and set its value to the string `'A'` to represent the connection between the nodes in both directions.
# --hints--
Your dictionary should have a `'B'` key.
```js
({ test: () => assert(__pyodide.runPython(`
graph = __locals.get("my_graph")
"B" in graph
`))
})
```
Your `'B'` key should have `'A'` as the value.
```js
({ test: () => assert(__pyodide.runPython(`
graph = __locals.get("my_graph")
graph["B"] == "A"
`))
})
```
Your dictionary should have an `'A'` key.
```js
({ test: () => assert(__pyodide.runPython(`
graph = __locals.get("my_graph")
"A" in graph
`))
})
```
Your `'A'` key should have `'B'` as the value.
```js
({ test: () => assert(__pyodide.runPython(`
graph = __locals.get("my_graph")
graph["A"] == "B"
`))
})
```
Your dictionary should have two keys.
```js
({ test: () => assert(__pyodide.runPython(`
graph = __locals.get("my_graph")
len(graph) == 2
`))
})
```
# --seed--
## --seed-contents--
```py
--fcc-editable-region--
my_graph = {
'A': 'B',
'age': 2
}
--fcc-editable-region--
```
@@ -0,0 +1,57 @@
---
id: 65b7cd2b7bd9a684ccf1dc16
title: Step 9
challengeType: 20
dashedName: step-9
---
# --description--
To iterate over the keys of a dictionary, you can simply put the dictionary into a `for` loop. The code below would print each key in the dictionary `dict`:
```py
for i in dict:
print(i)
```
Replace the `print()` call with a `for` loop that iterates over `copper` and prints each key.
# --hints--
You should not have `print(copper)` in your code.
```js
({ test: () => assert.isFalse(runPython(`_Node(_code).has_call("print(copper)")`)) })
```
You should create a `for` loop to iterate over the `copper` dictionary.
```js
({ test: () => assert(runPython(`_Node(_code).find_for_loops()[0].find_for_iter().is_equivalent("copper")`)) })
```
You should print each key of the `copper` inside your `for` loop.
```js
({ test: () => assert(runPython(`
var = _Node(_code).find_for_loops()[0].find_for_vars()
_Node(_code).find_for_loops()[0].find_bodies()[0].is_equivalent(f"print({var})")
`)) })
```
# --seed--
## --seed-contents--
```py
--fcc-editable-region--
copper = {
'species': 'guinea pig',
'age': 2
}
copper['food'] = 'hay'
copper['species'] = 'Cavia porcellus'
print(copper)
--fcc-editable-region--
```
@@ -0,0 +1,38 @@
---
id: 65b7cf140d34058d7ea8935f
title: Step 10
challengeType: 20
dashedName: step-10
---
# --description--
If you want to iterate over the values of the dictionary keys, one way is to use the `.values()` method.
Modify your `for` loop to iterate over `copper.values()` instead of `copper` and look at the output.
# --hints--
You should modify your `for` loop to iterate over `copper.values()` instead of `copper`.
```js
({ test: () => assert(runPython(`_Node(_code).find_for_loops()[0].find_for_iter().is_equivalent("copper.values()")`)) })
```
# --seed--
## --seed-contents--
```py
--fcc-editable-region--
copper = {
'species': 'guinea pig',
'age': 2
}
copper['food'] = 'hay'
copper['species'] = 'Cavia porcellus'
for i in copper:
print(i)
--fcc-editable-region--
```
@@ -0,0 +1,38 @@
---
id: 65b7d25992879698180e6a71
title: Step 11
challengeType: 20
dashedName: step-11
---
# --description--
Finally, if you want to be able to go through the key-value pairs, you can use the `.items()` method.
Modify your `for` loop to iterate over `copper.items()` instead of `copper.values()`.
# --hints--
You should mmodify your `for` loop to iterate over `copper.items()` instead of `copper.values()`.
```js
({ test: () => assert(runPython(`_Node(_code).find_for_loops()[0].find_for_iter().is_equivalent("copper.items()")`)) })
```
# --seed--
## --seed-contents--
```py
--fcc-editable-region--
copper = {
'species': 'guinea pig',
'age': 2
}
copper['food'] = 'hay'
copper['species'] = 'Cavia porcellus'
for i in copper.values():
print(i)
--fcc-editable-region--
```
@@ -0,0 +1,56 @@
---
id: 65b7d3319ebec69b983fb91b
title: Step 12
challengeType: 20
dashedName: step-12
---
# --description--
As you can see from the output, `.items()` creates a data structures that stores each key-value pair in a distinct tuple. To iterate over the elements in those tuples you can add a second loop variable:
```py
for i, j in dict.items():
print(i, j)
```
Modify your `for` loop to take two loop variables and print both of them inside the loop body.
# --hints--
You should modify your `for` loop to use two variables.
```js
({ test: () => assert(runPython(`
import ast
var = _Node(_code).find_for_loops()[0].find_for_vars()
isinstance(var.tree, ast.Tuple)
`)) })
```
You should print both loop variables inside your `for` loop.
```js
({ test: () => assert(runPython(`
var = _Node(_code).find_for_loops()[0].find_for_vars()
_Node(_code).find_for_loops()[0].find_bodies()[0].is_equivalent(f"print{var}")
`)) })
```
# --seed--
## --seed-contents--
```py
--fcc-editable-region--
copper = {
'species': 'guinea pig',
'age': 2
}
copper['food'] = 'hay'
copper['species'] = 'Cavia porcellus'
for i in copper.items():
print(i)
--fcc-editable-region--
```
@@ -2,7 +2,7 @@
id: 6557709b0aee699a6a00528c
title: 步驟 12
challengeType: 20
dashedName: step-12
dashedName: step-16
---
# --description--
@@ -2,7 +2,7 @@
id: 6557712d77ce2d9bd7e63afd
title: 步驟 13
challengeType: 20
dashedName: step-13
dashedName: step-18
---
# --description--
@@ -2,7 +2,7 @@
id: 6557716aadbd2d9c42c0e69a
title: 第 14 步
challengeType: 20
dashedName: step-14
dashedName: step-19
---
# --description--
@@ -2,7 +2,7 @@
id: 655771d889132f9ccd341060
title: 步驟15
challengeType: 20
dashedName: step-15
dashedName: step-20
---
# --description--
@@ -2,7 +2,7 @@
id: 65577236b056379d5dbc7000
title: 步驟 18
challengeType: 20
dashedName: step-18
dashedName: step-23
---
# --description--
@@ -2,7 +2,7 @@
id: 655773b0591c5f9f4045883e
title: 步驟 19
challengeType: 20
dashedName: step-19
dashedName: step-24
---
# --description--
@@ -2,7 +2,7 @@
id: 655773f8b8b5db9fc6d0ae76
title: 步驟 20
challengeType: 20
dashedName: step-20
dashedName: step-25
---
# --description--
@@ -2,7 +2,7 @@
id: 6557743527cb92a06417ea97
title: 步驟21
challengeType: 20
dashedName: step-21
dashedName: step-26
---
# --description--
@@ -2,7 +2,7 @@
id: 6557746aad2844a0cd864e12
title: 步驟 22
challengeType: 20
dashedName: step-22
dashedName: step-27
---
# --description--
@@ -2,7 +2,7 @@
id: 655774955b097ea14897db12
title: 步驟-23
challengeType: 20
dashedName: step-23
dashedName: step-28
---
# --description--
@@ -2,7 +2,7 @@
id: 655774d01daeeaa1978b99d5
title: 步驟 24
challengeType: 20
dashedName: step-24
dashedName: step-29
---
# --description--
@@ -2,7 +2,7 @@
id: 655775221059f5a20493d5d7
title: 步驟 25
challengeType: 20
dashedName: step-25
dashedName: step-30
---
# --description--
@@ -2,7 +2,7 @@
id: 655776db1eeae0a620e42a0d
title: 步驟 26
challengeType: 20
dashedName: step-26
dashedName: step-31
---
# --description--
@@ -2,7 +2,7 @@
id: 655777060d8ddea6741be1b1
title: 步驟 27
challengeType: 20
dashedName: step-27
dashedName: step-32
---
# --description--
@@ -2,7 +2,7 @@
id: 65577739f57ecca6c39bb4e9
title: 第 28 步
challengeType: 20
dashedName: step-28
dashedName: step-33
---
# --description--
@@ -2,7 +2,7 @@
id: 65577791ad8c26a7705e2919
title: 步驟 29
challengeType: 20
dashedName: step-29
dashedName: step-34
---
# --description--
@@ -2,7 +2,7 @@
id: 65577a17564ce8a8e06c1460
title: 第 30 步
challengeType: 20
dashedName: step-30
dashedName: step-35
---
# --description--
@@ -2,7 +2,7 @@
id: 65578c17d54dfab65cd54b95
title: 步驟 31
challengeType: 20
dashedName: step-31
dashedName: step-36
---
# --description--
@@ -2,7 +2,7 @@
id: 65578c74607d40b6d8c4757f
title: 步驟 32
challengeType: 20
dashedName: step-32
dashedName: step-37
---
# --description--
@@ -2,7 +2,7 @@
id: 65578cb031cd93b77a285db2
title: 步驟 33
challengeType: 20
dashedName: step-33
dashedName: step-38
---
# --description--
@@ -2,7 +2,7 @@
id: 65578cee7f2cb8b80127cce2
title: 步驟 34
challengeType: 20
dashedName: step-34
dashedName: step-39
---
# --description--
@@ -2,7 +2,7 @@
id: 65578d0f6c78a0b868a43b9c
title: 步驟 35
challengeType: 20
dashedName: step-35
dashedName: step-40
---
# --description--
@@ -2,7 +2,7 @@
id: 65578d4fc3afc3b8f554c882
title: 步驟 36
challengeType: 20
dashedName: step-36
dashedName: step-41
---
# --description--
@@ -2,7 +2,7 @@
id: 65578f895f2a65ba7a916804
title: 步驟 37
challengeType: 20
dashedName: step-37
dashedName: step-42
---
# --description--
@@ -2,7 +2,7 @@
id: 65578fcf00322dbad5dee05b
title: 步驟 38
challengeType: 20
dashedName: step-38
dashedName: step-43
---
# --description--
@@ -2,7 +2,7 @@
id: 655790d113d14dbb727eaf41
title: 步驟 40
challengeType: 20
dashedName: step-40
dashedName: step-45
---
# --description--
@@ -2,7 +2,7 @@
id: 6557910b0ebaeebc18209e90
title: 步驟 41
challengeType: 20
dashedName: step-41
dashedName: step-46
---
# --description--
@@ -2,7 +2,7 @@
id: 6557913b8fe5c0bc834c9f4f
title: 步驟 42
challengeType: 20
dashedName: step-42
dashedName: step-47
---
# --description--
@@ -2,7 +2,7 @@
id: 655791847db8a9bd0b685f40
title: 第 43 步
challengeType: 20
dashedName: step-43
dashedName: step-48
---
# --description--
@@ -2,7 +2,7 @@
id: 655791ae44c182bd92f31caa
title: 步驟 44
challengeType: 20
dashedName: step-44
dashedName: step-49
---
# --description--
@@ -2,7 +2,7 @@
id: 655791e6cf5e03be3de73451
title: 步驟 45
challengeType: 20
dashedName: step-45
dashedName: step-50
---
# --description--
@@ -2,7 +2,7 @@
id: 65579228c669fcbebffd01d5
title: 步驟 47
challengeType: 20
dashedName: step-47
dashedName: step-52
---
# --description--
@@ -2,7 +2,7 @@
id: 6557924d47c325bf27afbe51
title: 步驟 48
challengeType: 20
dashedName: step-48
dashedName: step-53
---
# --description--
@@ -2,7 +2,7 @@
id: 6557927ad11e58bf8c794b25
title: 步驟 50
challengeType: 20
dashedName: step-50
dashedName: step-55
---
# --description--
@@ -2,7 +2,7 @@
id: 6559d70c5161b16ff1d6530d
title: 步驟 49
challengeType: 20
dashedName: step-49
dashedName: step-54
---
# --description--
@@ -2,7 +2,7 @@
id: 6559d86fe1b8947954b9178d
title: 步驟 51
challengeType: 20
dashedName: step-51
dashedName: step-56
---
# --description--
@@ -2,7 +2,7 @@
id: 6559da1b7d75f088f5e6b89f
title: 第 52 步
challengeType: 20
dashedName: step-52
dashedName: step-57
---
# --description--
@@ -2,7 +2,7 @@
id: 6559da93115de78dbbdc7ba3
title: 第 54 步
challengeType: 20
dashedName: step-54
dashedName: step-59
---
# --description--
@@ -2,7 +2,7 @@
id: 6566195b0a021bb660b2b4b1
title: 步驟 16
challengeType: 20
dashedName: step-16
dashedName: step-21
---
# --description--
@@ -2,7 +2,7 @@
id: 65661b72d6745ebec6a96923
title: Step 17
challengeType: 20
dashedName: step-17
dashedName: step-22
---
# --description--
@@ -2,7 +2,7 @@
id: 6567722f53ad97d7ea6bb082
title: 步驟 46
challengeType: 20
dashedName: step-46
dashedName: step-51
---
# --description--
@@ -2,7 +2,7 @@
id: 65774ae7c3eee66fe79b9459
title: 步驟 53
challengeType: 20
dashedName: step-53
dashedName: step-58
---
# --description--
@@ -2,7 +2,7 @@
id: 657891ab9c1903f4e55433ba
title: 步驟 39
challengeType: 20
dashedName: step-39
dashedName: step-44
---
# --description--
@@ -2,7 +2,7 @@
id: 6579cbab9825b8170974c69a
title: 步驟 9
challengeType: 20
dashedName: step-9
dashedName: step-13
---
# --description--
@@ -2,7 +2,7 @@
id: 6579cd5f6dd62c189e53ddbb
title: 步驟 10
challengeType: 20
dashedName: step-10
dashedName: step-14
---
# --description--
@@ -2,7 +2,7 @@
id: 6579dd49fa8a8e1fd06b85a9
title: 步驟 11
challengeType: 20
dashedName: step-11
dashedName: step-15
---
# --description--
@@ -0,0 +1,75 @@
---
id: 65affe602a2a828b0382a058
title: Step 17
challengeType: 20
dashedName: step-17
---
# --description--
Replace the `'age'` key with the string `'B'` and set its value to the string `'A'` to represent the connection between the nodes in both directions.
# --hints--
Your dictionary should have a `'B'` key.
```js
({ test: () => assert(__pyodide.runPython(`
graph = __locals.get("my_graph")
"B" in graph
`))
})
```
Your `'B'` key should have `'A'` as the value.
```js
({ test: () => assert(__pyodide.runPython(`
graph = __locals.get("my_graph")
graph["B"] == "A"
`))
})
```
Your dictionary should have an `'A'` key.
```js
({ test: () => assert(__pyodide.runPython(`
graph = __locals.get("my_graph")
"A" in graph
`))
})
```
Your `'A'` key should have `'B'` as the value.
```js
({ test: () => assert(__pyodide.runPython(`
graph = __locals.get("my_graph")
graph["A"] == "B"
`))
})
```
Your dictionary should have two keys.
```js
({ test: () => assert(__pyodide.runPython(`
graph = __locals.get("my_graph")
len(graph) == 2
`))
})
```
# --seed--
## --seed-contents--
```py
--fcc-editable-region--
my_graph = {
'A': 'B',
'age': 2
}
--fcc-editable-region--
```
@@ -0,0 +1,57 @@
---
id: 65b7cd2b7bd9a684ccf1dc16
title: Step 9
challengeType: 20
dashedName: step-9
---
# --description--
To iterate over the keys of a dictionary, you can simply put the dictionary into a `for` loop. The code below would print each key in the dictionary `dict`:
```py
for i in dict:
print(i)
```
Replace the `print()` call with a `for` loop that iterates over `copper` and prints each key.
# --hints--
You should not have `print(copper)` in your code.
```js
({ test: () => assert.isFalse(runPython(`_Node(_code).has_call("print(copper)")`)) })
```
You should create a `for` loop to iterate over the `copper` dictionary.
```js
({ test: () => assert(runPython(`_Node(_code).find_for_loops()[0].find_for_iter().is_equivalent("copper")`)) })
```
You should print each key of the `copper` inside your `for` loop.
```js
({ test: () => assert(runPython(`
var = _Node(_code).find_for_loops()[0].find_for_vars()
_Node(_code).find_for_loops()[0].find_bodies()[0].is_equivalent(f"print({var})")
`)) })
```
# --seed--
## --seed-contents--
```py
--fcc-editable-region--
copper = {
'species': 'guinea pig',
'age': 2
}
copper['food'] = 'hay'
copper['species'] = 'Cavia porcellus'
print(copper)
--fcc-editable-region--
```

Some files were not shown because too many files have changed in this diff Show More