MicroPython Cookbook
上QQ阅读APP看书,第一时间看更新

How to do it...

  1. Open the REPL through your preferred application.
  2. 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
  1. 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
>>>
  1. 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