Line: 1 to 1 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Solutions to Exercise 1: REPL and standard Python programmingExercise 1: Use of REPL | |||||||||||
Line: 24 to 24 | |||||||||||
Exercise 3: ConditionsThere is nothing much new in this exercise except that it shows how to use conditional statements. | |||||||||||
Added: | |||||||||||
> > | The first version uses the fixed values 5 and 7: https://iotworkshop.africa/pub/IoT_Course_English/SolutionsToREPLAndStandardPythonProgramming/conditionsV1.py.txt The second version takes user input, splits it along spaces and makes sure that exactly 2 tokens have been given https://iotworkshop.africa/pub/IoT_Course_English/SolutionsToREPLAndStandardPythonProgramming/conditionsV2.py.txt The third version also checks that the 2 tokens are valid integer numbers https://iotworkshop.africa/pub/IoT_Course_English/SolutionsToREPLAndStandardPythonProgramming/conditionsV3.py.txt | ||||||||||
Exercise 4: The Fibonacci Series | |||||||||||
Changed: | |||||||||||
< < | In this exercise we try to implement a mathematical function. This should allow you to write your own small algorithm and test it. The function you develop here will be used in exercise 6.
Exercise 5: Some maths: Calculate the sine function | ||||||||||
> > | In this exercise we try to implement a mathematical function. This should allow you to write your own small algorithm and test it. The function you develop here will be used in exercise 6. Again there are 2 versions: The first one calculates the Fibonacci series F(n) where n is given by the user:
https://iotworkshop.africa/pub/IoT_Course_English/SolutionsToREPLAndStandardPythonProgramming/fibonacciV1.py.txt
while in the second version the user gives a maximum number not to be exceeded.
https://iotworkshop.africa/pub/IoT_Course_English/SolutionsToREPLAndStandardPythonProgramming/fibonaciiV2.py.txt
Exercise 5: A bit of Mathematics: Calculate the sine function | ||||||||||
Changed: | |||||||||||
< < | Here we implement the calculation of the sine function we used with REPL in the first exercise. It shows how use external modules/libraries. | ||||||||||
> > | Here we implement the calculation of the sine function we used with REPL in the first exercise. It shows how use external modules/libraries. This exercise is pretty simple. https://iotworkshop.africa/pub/IoT_Course_English/SolutionsToREPLAndStandardPythonProgramming/math.py.txt | ||||||||||
Exercise 6: ClassesThis exercise is a bit bigger! It shows you how to develop your own modules and your own classes. In addition you may study some interesting mathematical number series. The last 4 series are actually approximations to well known mathematical constants: | |||||||||||
Line: 37 to 57 | |||||||||||
| |||||||||||
Changed: | |||||||||||
< < | When trying to get a good approximation for these numbers you will have to calculate a big number of iterations and you may see a difference between running the program on the PC and running it on the ESP32 where you may see this: | ||||||||||
> > | When trying to get a good approximation for these numbers you will have to calculate a big number of iterations and you may see a difference between running the program on the PC and running it on the ESP32 where you may see this:3.14159 26535 89793 23846 | ||||||||||
The reason is simple: My PC has 16 GBytes of RAM memory while the ESP32 has 520 kBytes of RAM. When calculating a big number of iterations you will not be able to keep the intermediate results in a list. | |||||||||||
Added: | |||||||||||
> > | For comparison, here are the correct numbers for pi, e and ln(2)
| ||||||||||
The other difference is that the ESP32 has no high resolution screen attached to it such that plotting does not make much sense. (TFT screens do exist and can be attached to the ESP32 such that this statement must be taken with a bit of caution) Here is a plot of the factorial series and the Fibonacci numbers. Since factorial uses multiplication while Fibonacci uses additions, factorial increases much faster. | |||||||||||
Line: 57 to 81 | |||||||||||
Added: | |||||||||||
> > | ... and here is the code: First we have the class implementing the calculation of the number series: https://iotworkshop.africa/pub/IoT_Course_English/SolutionsToREPLAndStandardPythonProgramming/mathSeries.py.txt Then the test program, calling each if the methods in the class: https://iotworkshop.africa/pub/IoT_Course_English/SolutionsToREPLAndStandardPythonProgramming/mathSeriesTest.py.txt and finally the program which generates the plots: https://iotworkshop.africa/pub/IoT_Course_English/SolutionsToREPLAndStandardPythonProgramming/mathSeriesPlot.py.txt | ||||||||||
-- Uli Raich - 2020-05-03
Comments | |||||||||||
Line: 70 to 108 | |||||||||||
| |||||||||||
Changed: | |||||||||||
< < |
| ||||||||||
> > |
| ||||||||||
| |||||||||||
Added: | |||||||||||
> > |
|