Difference: REPLAndStandardPythonProgramming (4 vs. 5)

Revision 52020-05-04 - UliRaich

Line: 1 to 1
 
META TOPICPARENT name="Exercises"

Course on Internet of Things

Exercises Session 1:

Introductory remarks:

Changed:
<
<
The scripts we are going to develop during these exercises do not depend on any system issues: We do not use command line arguments not available in MicroPython nor do we use any hardware specific features which are not available on a PC. The exercises can therefore be developed and run on the ESP32 but also on any standard PC with Python3 installed.
>
>
The scripts we are going to develop during this exercise session do not depend on any system issues: We do not use command line arguments not available in MicroPython nor do we use any hardware specific features which are not available on a PC. The exercises can therefore be developed and run on the ESP32 but also on any standard PC with Python3 installed.
 

Exercise 1: Use of REPL

Changed:
<
<
Connect to your ESP32 with minicom or thonny.
>
>
Connect to your ESP32 with minicom or thonny. You may try the same thing running Python3 on your PC.
  Using REPL:
  • print “Hello World!”

Line: 65 to 65
 
  • Calculate and print out the Fibonacci numbers up to F(n). Get n from the user where n >= 0
Try your program for n=0, n=1, n=2, n=3, n=20

  • Ask the user up to which is the maximum number up to which you should calculate.
Added:
>
>

Exercise 5: Some maths: Calculate the sine function

Write a script that asks the user for an angle in degrees. Calculate the sine of this angle.

Exercise 6: Classes

Write a Python class with methods calculation mathematical number series. These series should be calculated:

  • The Fibonacci numbers up to F(n). n is passed as parameter to the method
  • The Fibonacci numbers smaller than max. max is passed as parameter to the method
  • The prime numbers up to max
  • Factorial:
    factorial.png
  • The geometric number series:
    geometric.png
  • The harmonic number series:
    harmonic.png
    Can you tell what the following series calculate?
ln2.png pi.png e.png
Add these series to your class and try. Write a test script exercising the different methods.

When running on a PC you may want to plot the series as well.

  -- Uli Raich - 2020-05-03
Line: 75 to 92
 
META FILEATTACHMENT attachment="conversionError.png" attr="" comment="" date="1588534969" name="conversionError.png" path="conversionError.png" size="19759" user="UliRaich" version="1"
META FILEATTACHMENT attachment="calcOk.png" attr="" comment="" date="1588535543" name="calcOk.png" path="calcOk.png" size="22212" user="UliRaich" version="1"
META FILEATTACHMENT attachment="conditions.png" attr="" comment="" date="1588537519" name="conditions.png" path="conditions.png" size="29528" user="UliRaich" version="1"
Added:
>
>
META FILEATTACHMENT attachment="factorial.png" attr="" comment="" date="1588596529" name="factorial.png" path="factorial.png" size="2855" user="UliRaich" version="1"
META FILEATTACHMENT attachment="geometric.png" attr="" comment="" date="1588596529" name="geometric.png" path="geometric.png" size="3970" user="UliRaich" version="1"
META FILEATTACHMENT attachment="ln2.png" attr="" comment="" date="1588596529" name="ln2.png" path="ln2.png" size="2046" user="UliRaich" version="1"
META FILEATTACHMENT attachment="pi.png" attr="" comment="" date="1588596529" name="pi.png" path="pi.png" size="2785" user="UliRaich" version="1"
META FILEATTACHMENT attachment="harmonic.png" attr="" comment="" date="1588596798" name="harmonic.png" path="harmonic.png" size="1631" user="UliRaich" version="1"
META FILEATTACHMENT attachment="e.png" attr="" comment="" date="1588596991" name="e.png" path="e.png" size="1931" user="UliRaich" version="1"
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback