Skip to content

Commit b921ab2

Browse files
committed
REPL review
1 parent 755c248 commit b921ab2

File tree

1 file changed

+36
-15
lines changed
  • content/micropython/03.micropython/02.enviroment/01.repl

1 file changed

+36
-15
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
---
2-
3-
featured: micropython-101
4-
title: '1. Micropython Environment - REPL'
2+
title: 'REPL'
53
description: 'Learn the basics for loops on MicroPython.'
64
author: 'Pedro Lima'
7-
hero_image: "./hero-banner.png"
8-
5+
tags: [MicroPython, REPL]
96
---
107

11-
REPL, which stands for Read-Eval-Print Loop, is an interactive environment that makes programming in MicroPython fast and flexible. REPL allows you to enter code line-by-line and see the results immediately. Although sometimes overlooked it is a great way for testing and debugging on the fly.
8+
**REPL**, short for **Read-Eval-Print Loop**, is an interactive environment that makes programming in MicroPython fast and flexible. REPL allows you to enter code line-by-line and see the results immediately. Although sometimes overlooked it is a great way for testing and debugging on the fly.
129

13-
We’ll walk through what REPL does, why it’s useful, and how you can use it to enhance your MicroPython experience.
10+
In this guide, we’ll go through how the REPL functions, why it’s useful, and how you can use it to enhance your MicroPython experience.
1411

1512
## What is REPL?
1613

@@ -23,6 +20,10 @@ The REPL process involves four basic steps:
2320

2421
Think of REPL as a conversation between you and your MicroPython environment, where each line you type gets an instant response, making it ideal for exploring ideas and troubleshooting.
2522

23+
## print()
24+
25+
26+
2627
## How REPL Works in MicroPython
2728

2829
In MicroPython, REPL can be accessed via Arduino Labs for MicroPython terminal, enabling you to run code in real-time directly on your device. Here’s a step-by-step guide on using it:
@@ -32,22 +33,42 @@ In MicroPython, REPL can be accessed via Arduino Labs for MicroPython terminal,
3233
3. **See Results Instantly**: Any output, return values, or errors are displayed right away. If your code contains expressions, REPL will evaluate and print them for you.
3334
4. **Iterate**: The loop resets, and you can immediately enter more code, building on previous commands or testing new lines independently.
3435

35-
## Example: Using REPL in MicroPython
36+
## Example: Store and Print Your Name
3637

37-
Let's see a simple REPL session to add two numbers interactively:
38+
Let's create a REPL session, where you will enter your name, and then print it.
39+
40+
Connect your board, and click on the **RUN** button with an empty script, then enter the following things in the REPL, line by line.
41+
42+
```
43+
>>> name = "Pedro"
44+
>>> name
45+
```
46+
47+
When writing `name` in the REPL, (after `name = "Pedro"`), we should get:
48+
49+
```
50+
'Pedro'
51+
```
52+
53+
![TODO: GIF showing step by step so people understand to run each individually]()
54+
55+
## Example: Perform a Calculation in the REPL
56+
57+
Now let's create a REPL session that performs a calculation, by adding two numbers together:
3858

3959
```python
4060
>>> a = 5
4161
>>> b = 3
4262
>>> a + b
4363
8
4464
```
45-
TODO: GIF showing step by step so people understand to run each individually !()[]
4665

47-
In this REPL session:
66+
![TODO: GIF showing step by step so people understand to run each individually]()
67+
68+
In this REPL session, we:
4869

49-
- **Define variables**: We set `a` to 5 and `b` to 3.
50-
- **Perform calculation**: Entering `a + b` immediately returns `8`, showing the result without having to write a full script.
70+
- Defined variables by setting `a` to `5` and `b` to `3`.
71+
- Performed a calculation by entering `a + b`, which immediately returns `8`, showing the result without having to write a full script.
5172

5273
## Common Uses of REPL
5374

@@ -57,7 +78,7 @@ REPL is particularly useful for:
5778
- **Debugging**: Test small parts of a larger project interactively.
5879
- **Learning**: Practice MicroPython commands and get instant feedback, ideal for beginners.
5980

60-
## Going Further With REPL
81+
## Summary
6182

6283
REPL in MicroPython is an useful tool that enables instant testing and feedback, making coding more interactive and efficient. Whether you're learning, debugging, or exploring ideas, REPL provides a flexible and powerful coding experience.
6384

@@ -68,4 +89,4 @@ REPL in MicroPython is an useful tool that enables instant testing and feedback,
6889
- **Debug Variable Values**: Enter and modify variables on the spot to test changes in data or simulate inputs, allowing you to observe how your program behaves step-by-step.
6990
- **Practice Logical Expressions**: Experiment with logical statements and conditionals to understand how `if` statements, comparisons, and loops work in MicroPython.
7091

71-
By mastering REPL, you’ll be well-equipped to make the most of MicroPython’s interactive capabilities and streamline your development process.
92+
By mastering REPL, you’ll be well-equipped to make the most of MicroPython’s interactive capabilities and streamline your development process.

0 commit comments

Comments
 (0)