chore(curriculum): remove __locals from shortest path project (#54783)

Co-authored-by: Dario-DC <105294544+Dario-DC@users.noreply.github.com>
This commit is contained in:
Ilenia
2024-05-15 09:58:04 +02:00
committed by GitHub
parent 3c9bbf2167
commit 4b1184672e
15 changed files with 32 additions and 71 deletions

View File

@@ -24,7 +24,6 @@ You should add a new key-value pair to your `copper` dictionary.
```js
({ test: () => assert(__pyodide.runPython(`
copper = __locals.get("copper")
len(copper) == 1
`))
})
@@ -34,7 +33,6 @@ You should have a `species` key with the value `guinea pig` inside your `copper`
```js
({ test: () => assert(__pyodide.runPython(`
copper = __locals.get("copper")
copper == {"species": "guinea pig"}
`))
})

View File

@@ -15,8 +15,7 @@ Your dictionary should have an `A` key.
```js
({ test: () => assert(__pyodide.runPython(`
graph = __locals.get("my_graph")
"A" in graph
"A" in my_graph
`))
})
```
@@ -25,8 +24,7 @@ Your `A` key should have `B` as the value.
```js
({ test: () => assert(__pyodide.runPython(`
graph = __locals.get("my_graph")
graph["A"] == "B"
my_graph["A"] == "B"
`))
})
```
@@ -35,8 +33,7 @@ Your dictionary should have an `B` key.
```js
({ test: () => assert(__pyodide.runPython(`
graph = __locals.get("my_graph")
"B" in graph
"B" in my_graph
`))
})
```
@@ -45,8 +42,7 @@ Your `B` key should have `A` as the value.
```js
({ test: () => assert(__pyodide.runPython(`
graph = __locals.get("my_graph")
graph["B"] == "A"
my_graph["B"] == "A"
`))
})
```
@@ -55,8 +51,7 @@ Your dictionary should have two keys.
```js
({ test: () => assert(__pyodide.runPython(`
graph = __locals.get("my_graph")
len(graph) == 2
len(my_graph) == 2
`))
})
```

View File

@@ -17,9 +17,8 @@ Your dictionary should have 3 keys — `A`, `B`, and `C`.
```js
({ test: () => assert(__pyodide.runPython(`
graph = __locals.get("my_graph")
key_list = ["A", "B", "C"]
len(graph) == 3 and all(key in graph for key in key_list)
len(my_graph) == 3 and all(key in my_graph for key in key_list)
`))
})
```
@@ -28,8 +27,7 @@ Your dictionary should have 3 keys — `A`, `B`, and `C`.
```js
({ test: () => assert(__pyodide.runPython(`
graph = __locals.get("my_graph")
graph["A"] == "B"
my_graph["A"] == "B"
`))
})
```
@@ -38,8 +36,7 @@ Your dictionary should have 3 keys — `A`, `B`, and `C`.
```js
({ test: () => assert(__pyodide.runPython(`
graph = __locals.get("my_graph")
type(graph["B"]) is list
type(my_graph["B"]) is list
`))
})
```
@@ -48,8 +45,7 @@ The value of `my_graph["B"]` should be a list containing the other two nodes.
```js
({ test: () => assert(__pyodide.runPython(`
graph = __locals.get("my_graph")
len(graph["B"]) == 2 and "A" in graph["B"] and "C" in graph["B"]
len(my_graph["B"]) == 2 and "A" in my_graph["B"] and "C" in my_graph["B"]
`))
})
```
@@ -58,8 +54,7 @@ The value of `my_graph["C"]` should be the connected node.
```js
({ test: () => assert(__pyodide.runPython(`
graph = __locals.get("my_graph")
graph["C"] == "B"
my_graph["C"] == "B"
`))
})
```

View File

@@ -15,9 +15,8 @@ Your dictionary should have 4 keys called `A`, `B`, `C`, and `D`.
```js
({ test: () => assert(__pyodide.runPython(`
graph = __locals.get("my_graph")
key_list = ["A", "B", "C", "D"]
len(graph) == 4 and all(key in graph for key in key_list)
len(my_graph) == 4 and all(key in my_graph for key in key_list)
`))
})
```
@@ -26,8 +25,7 @@ Your dictionary should have 4 keys called `A`, `B`, `C`, and `D`.
```js
({ test: () => assert(__pyodide.runPython(`
graph = __locals.get("my_graph")
type(graph["A"]) is list
type(my_graph["A"]) is list
`))
})
```
@@ -36,8 +34,7 @@ Your dictionary should have 4 keys called `A`, `B`, `C`, and `D`.
```js
({ test: () => assert(__pyodide.runPython(`
graph = __locals.get("my_graph")
len(graph["A"]) == 2 and "B" in graph["A"] and "D" in graph["A"]
len(my_graph["A"]) == 2 and "B" in my_graph["A"] and "D" in my_graph["A"]
`))
})
```
@@ -46,8 +43,7 @@ Your dictionary should have 4 keys called `A`, `B`, `C`, and `D`.
```js
({ test: () => assert(__pyodide.runPython(`
graph = __locals.get("my_graph")
type(graph["B"]) is list
type(my_graph["B"]) is list
`))
})
```
@@ -56,8 +52,7 @@ Your dictionary should have 4 keys called `A`, `B`, `C`, and `D`.
```js
({ test: () => assert(__pyodide.runPython(`
graph = __locals.get("my_graph")
len(graph["B"]) == 2 and "A" in graph["B"] and "C" in graph["B"]
len(my_graph["B"]) == 2 and "A" in my_graph["B"] and "C" in my_graph["B"]
`))
})
```
@@ -66,8 +61,7 @@ Your dictionary should have 4 keys called `A`, `B`, `C`, and `D`.
```js
({ test: () => assert(__pyodide.runPython(`
graph = __locals.get("my_graph")
type(graph["C"]) is list
type(my_graph["C"]) is list
`))
})
```
@@ -76,8 +70,7 @@ Your dictionary should have 4 keys called `A`, `B`, `C`, and `D`.
```js
({ test: () => assert(__pyodide.runPython(`
graph = __locals.get("my_graph")
len(graph["C"]) == 2 and "B" in graph["C"] and "D" in graph["C"]
len(my_graph["C"]) == 2 and "B" in my_graph["C"] and "D" in my_graph["C"]
`))
})
```
@@ -86,8 +79,7 @@ Your dictionary should have 4 keys called `A`, `B`, `C`, and `D`.
```js
({ test: () => assert(__pyodide.runPython(`
graph = __locals.get("my_graph")
type(graph["D"]) is list
type(my_graph["D"]) is list
`))
})
```
@@ -96,8 +88,7 @@ Your dictionary should have 4 keys called `A`, `B`, `C`, and `D`.
```js
({ test: () => assert(__pyodide.runPython(`
graph = __locals.get("my_graph")
len(graph["D"]) == 2 and "A" in graph["D"] and "C" in graph["D"]
len(my_graph["D"]) == 2 and "A" in my_graph["D"] and "C" in my_graph["D"]
`))
})
```

View File

@@ -29,9 +29,8 @@ Your dictionary should have 4 keys called `A`, `B`, `C`, and `D`.
```js
({ test: () => assert(__pyodide.runPython(`
graph = __locals.get("my_graph")
key_list = ["A", "B", "C", "D"]
len(graph) == 4 and all(key in graph for key in key_list)
len(my_graph) == 4 and all(key in my_graph for key in key_list)
`))
})
```
@@ -40,8 +39,7 @@ Your dictionary should have 4 keys called `A`, `B`, `C`, and `D`.
```js
({ test: () => assert(__pyodide.runPython(`
graph = __locals.get("my_graph")
type(graph["A"]) is list and all(type(i) is tuple for i in graph["A"])
type(my_graph["A"]) is list and all(type(i) is tuple for i in my_graph["A"])
`))
})
```
@@ -50,9 +48,8 @@ Your dictionary should have 4 keys called `A`, `B`, `C`, and `D`.
```js
({ test: () => assert(__pyodide.runPython(`
graph = __locals.get("my_graph")
tuples = [("B", 3), ("D", 1)]
len(graph["A"]) == 2 and all(t in graph["A"] for t in tuples)
len(my_graph["A"]) == 2 and all(t in my_graph["A"] for t in tuples)
`))
})
```

View File

@@ -18,8 +18,7 @@ You should have a `shortest_path` function.
```js
({ test: () => assert(__pyodide.runPython(`
import inspect
f = __locals.get("shortest_path")
inspect.isfunction(f)
inspect.isfunction(shortest_path)
`))
})
```

View File

@@ -18,8 +18,7 @@ Your function should accept `graph` and `start` as the parameters, in this order
```js
({ test: () => assert(__pyodide.runPython(`
import inspect
f = __locals.get("shortest_path")
sig = str(inspect.signature(f))
sig = str(inspect.signature(shortest_path))
sig == '(graph, start)'
`))
})

View File

@@ -24,8 +24,7 @@ The `target` parameter should have the default value of an empty string.
```js
({ test: () => assert(__pyodide.runPython(`
import inspect
foo = __locals.get("shortest_path")
sig = str(inspect.signature(foo))
sig = str(inspect.signature(shortest_path))
sig == "(graph, start, target='')"
`))
})

View File

@@ -15,8 +15,7 @@ Now modify `my_graph["B"]` into a list of tuples. The `B-C` distance is `4`.
```js
({ test: () => assert(__pyodide.runPython(`
graph = __locals.get("my_graph")
type(graph["B"]) is list and all(type(i) is tuple for i in graph["B"])
type(my_graph["B"]) is list and all(type(i) is tuple for i in my_graph["B"])
`))
})
```
@@ -25,9 +24,8 @@ Now modify `my_graph["B"]` into a list of tuples. The `B-C` distance is `4`.
```js
({ test: () => assert(__pyodide.runPython(`
graph = __locals.get("my_graph")
tuples = [("A", 3), ("C", 4)]
len(graph["B"]) == 2 and all(t in graph["B"] for t in tuples)
len(my_graph["B"]) == 2 and all(t in my_graph["B"] for t in tuples)
`))
})
```

View File

@@ -15,8 +15,7 @@ In the same way, modify the remaining two lists considering that the `C-D` dista
```js
({ test: () => assert(__pyodide.runPython(`
graph = __locals.get("my_graph")
type(graph["C"]) is list and all(type(i) is tuple for i in graph["C"])
type(my_graph["C"]) is list and all(type(i) is tuple for i in my_graph["C"])
`))
})
```
@@ -25,9 +24,8 @@ In the same way, modify the remaining two lists considering that the `C-D` dista
```js
({ test: () => assert(__pyodide.runPython(`
graph = __locals.get("my_graph")
tuples = [("B", 4), ("D", 7)]
len(graph["C"]) == 2 and all(t in graph["C"] for t in tuples)
len(my_graph["C"]) == 2 and all(t in my_graph["C"] for t in tuples)
`))
})
```
@@ -36,8 +34,7 @@ In the same way, modify the remaining two lists considering that the `C-D` dista
```js
({ test: () => assert(__pyodide.runPython(`
graph = __locals.get("my_graph")
type(graph["D"]) is list and all(type(i) is tuple for i in graph["D"])
type(my_graph["D"]) is list and all(type(i) is tuple for i in my_graph["D"])
`))
})
```
@@ -46,9 +43,8 @@ In the same way, modify the remaining two lists considering that the `C-D` dista
```js
({ test: () => assert(__pyodide.runPython(`
graph = __locals.get("my_graph")
tuples = [("A", 1), ("C", 7)]
len(graph["D"]) == 2 and all(t in graph["D"] for t in tuples)
len(my_graph["D"]) == 2 and all(t in my_graph["D"] for t in tuples)
`))
})
```

View File

@@ -26,7 +26,6 @@ You should modify `my_graph` into the provided graph.
```js
({ test: () => assert(__pyodide.runPython(`
graph = __locals.get("my_graph")
g = {
'A': [('B', 5), ('C', 3), ('E', 11)],
'B': [('A', 5), ('C', 1), ('F', 2)],
@@ -35,7 +34,7 @@ You should modify `my_graph` into the provided graph.
'E': [('A', 11), ('C', 5), ('D', 9)],
'F': [('B', 2), ('D', 3)]
}
graph == g
my_graph == g
`))
})

View File

@@ -28,7 +28,6 @@ Your `copper` variable should have the value of an empty dictionary. Use a pair
```js
({ test: () => assert(__pyodide.runPython(`
copper = __locals.get("copper")
copper == {}
`))
})

View File

@@ -17,7 +17,6 @@ You should add a new key-value pair to your `copper` dictionary.
```js
({ test: () => assert(__pyodide.runPython(`
copper = __locals.get("copper")
len(copper) == 2
`))
})
@@ -27,7 +26,6 @@ You should have an `age` key with the value `2` just after `'species': 'guinea p
```js
({ test: () => assert(__pyodide.runPython(`
copper = __locals.get("copper")
copper == {"species": "guinea pig", "age": 2}
`))
})

View File

@@ -26,7 +26,6 @@ You should not modify your dictionary.
```js
({ test: () => assert(__pyodide.runPython(`
copper = __locals.get("copper")
copper == {"species": "guinea pig", "age": 2}
`))
})

View File

@@ -26,7 +26,6 @@ Your `my_graph` variable should be a dictionary.
```js
({ test: () => assert(__pyodide.runPython(`
my_graph = __locals.get("my_graph")
type(my_graph) is dict
`))
})