Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add REPL mode to browser. #267

Open
donkirkby opened this issue Mar 26, 2020 · 0 comments
Open

Add REPL mode to browser. #267

donkirkby opened this issue Mar 26, 2020 · 0 comments

Comments

@donkirkby
Copy link
Owner

donkirkby commented Mar 26, 2020

While reviewing tutorials for #262, I found a lot of them use the REPL at the start. A typical example:

>>> 2 + 2
4
>>> 50 - 5*6
20
>>> (50 - 5*6) / 4
5.0
>>> 8 / 5  # division always returns a floating point number
1.6

Some of them use multiline expressions:

>>> for i in range(5):
...     print(i)
...
0
1
2
3
4

I think new learners find those are easier to approach than full scripts, but they don't fit with the live coding approach. A hybrid approach would be to add a REPL mode that lets the user type new lines at the end of each code sample. Ideally, the up arrow would even let them cycle through the lines in the sample.

The code module has tools to emulate a REPL, including help deciding when an expression is complete and when you should ask for another line.

It might be possible to fit this into the live tutorial model using cloze tests. The goal could be a REPL session with blanks, and the student has to follow the pattern and fill in the blanks. For example, a goal might look like this:

>>> a = 2
>>> b = 3
>>> a ? b
6

The student would need to replace the ? with *. I guess a rewind button would be needed to fix mistakes.

To define a REPL section, end the code with >>>. The goal can contain lines that start with ^^^ to mark clozes.

>>> a = 2
>>> b = 3
>>>

### Goal ###
>>> a = 2
>>> b = 3
>>> a * b
^^^   ^
6
@donkirkby donkirkby added this to the Near future milestone Mar 26, 2020
@donkirkby donkirkby removed this from the PyCascades Sprint milestone Sep 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant