Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
Exercises | ||||||||
Changed: | ||||||||
< < | A bit of programming | |||||||
> > |
First exercise session:A bit of programming | |||||||
Connect your ESP32 to the PC using the micro USB cable and start thonny. Locate the shell window and check if you see the PEPL prompt ">>>". If not, try to press <enter>. Make sure the shell window has the input focus. If this does not work, press the stop button. If this also doesn't help, press the reset button on the ESP32 CPU board. | ||||||||
Changed: | ||||||||
< < | Playing with REPL | |||||||
> > | Playing with REPL | |||||||
| ||||||||
Changed: | ||||||||
< < | Hello World | |||||||
> > | Hello World | |||||||
Instead of working on the shell window, we will now write a Python script (a small program). For this to work, select File -> New. This will create an editor window named <untitled>. Save this empty program to the disk on your PC. Select File -> Save, select "This Computer" give it a file name (e.g. hello.py) and press "OK". The window title changes to hello.py.
Now enter
print("Hello World!") | ||||||||
Changed: | ||||||||
< < | Finally, run the program by pressing the green button with the white triangle. You should see "Hello World!" printed in the shell window. | |||||||
> > | Finally, run the program by pressing the green button with the white triangle. You should see "Hello World!" printed in the shell window. This is what you should get:
Some ArithmeticAssign 2 values to 2 variables a and b. Calculate the sum, the difference, the product and the division and print the results. Start assigning integer values. Try integer and float division. Then assign float values and try again.ConditionsAssign again 2 values to 2 variables a and b with a being bigger than b . In your program, check if a is equal, bigger or smaller than b. Modify the values you assign to a and b, with b now bigger than a and try again. What happens if you test:if a: print("yes") else: print("No")Try this with a being assigned to zero and a being assigned to 7. What do you conclude? LoopsWrite a script that prints "Hello World!" forever. You can stop the program with the red Stop button. Write a program that prints "Hello World!" 7 times. Do this using a while loop and in a second program, using a for loop, Which of the programs is more elegant?This is the end of the first exercise sessionSecond exercise session | |||||||
-- Uli Raich - 2022-10-14
Comments\ No newline at end of file | ||||||||
Added: | ||||||||
> > |
|