Difference: REPLAndStandardPythonProgramming (6 vs. 7)

Revision 72020-05-05 - UliRaich

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

Course on Internet of Things

Exercises Session 1:

Line: 47 to 47
 
5.3+4b7 not ok
empty string not ok
5.3+. not ok
Added:
>
>
5.3+ not ok
 Try also several spaces in between operands and operator.

Exercise 3: Conditions

Changed:
<
<
Like in exercise2, start with 2 numbers a,b with values 5 and 3. In your program check which of the 2 numbers is bigger and print the result.
>
>
Like in exercise2, start with 2 numbers a,b with values 5 and 7. In your program check which of the 2 numbers is bigger and print the result.
  Then improve the program asking the user for 2 integer numbers. Make sure he enters 2 correct numbers and capture possible errors. This is a typical output:
Line: 65 to 66
 
  • 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.
Changed:
<
<

Exercise 5: Some maths: Calculate the sine function

>
>

Exercise 5: A bit of Mathematics: 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

Line: 81 to 82
 
ln2.png pi.png

wallis1.png

e.png
Add these series to your class and try. Write a test script exercising the different methods.
Changed:
<
<
When running on a PC you may want to plot the series as well.
>
>
In order to make this exercise run on the ESP32 you must first upload your mathSeries.py module implementing the MathSeries class into the file system of the ESP32. Create a directory called lib on the ESP32 file system and put your module there:

ampy mkdir /lib

ampy put mathSeries.py /lib/mathSeries.py

Once this is done, go to the REPL window of thonny and

import mathSeries

You can now create an instance of the MathSeries class:

series = mathSeries.MathSeries()

When running on a PC you may want to plot the series as well. If you don't know how to plot data in Python, you will find all the information needed here:
https://matplotlib.org/3.2.1/index.html

  -- Uli Raich - 2020-05-03
 
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