added new examples

This commit is contained in:
gijsio
2020-07-27 12:11:16 +02:00
parent cf489756a3
commit 70154eeaf1
2 changed files with 30 additions and 3 deletions

View File

@@ -6,9 +6,17 @@ aliases:
- chapter/tutorials/basic/print
---
Using the `print()` statements in your python script is quite easy. But did you know you can also concatinate strigns and variables inline? If you are formiliar with C, it's functionality is similar to the `printf()` function, but with `\n` always included.
Using the `print()` statements in your python script is quite easy. But did you know you can also concatinate strigns and variables inline? If you are familiar with C, it's functionality is similar to the `printf()` function, but with `\n` always included.
```python
import machine
print("hello world")
print("hello world.", end='') # do not end line
#you can also specify different endings, like additional text, tabs or any other escape characters
for i in range(0,9):
print(".", end='')
print("\n") #feed a new line
print("\t tabbed in")
#you can specify a variable into the string as well!
print("hello world: " + str(machine.rng()) + " random number" )
```