上QQ阅读APP看书,第一时间看更新
How to do it...
- Open the REPL through your preferred application.
- Many of the same capabilities provided by the REPL in CPython also work in the MicroPython implementation. The last returned value can be accessed with _:
>>> 2 + 2
4
>>> _ + 2
6
Continuation lines are also supported, making it possible to define functions or for loops through the REPL, as shown in the following output:
>>> def add(a, b):
... return a + b
...
...
...
>>> add(2, 2)
4
>>>
- Arbitrary precision integers are also supported, even on constrained microcontroller hardware. The following code shows arithmetic with integers beyond the limit of a 64-bit integer value:
>>> 2**100 + 2**101
3802951800684688204490109616128