Difference: ExerciseSheets (4 vs. 5)

Revision 52022-10-15 - UliRaich

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

Exercises

Line: 43 to 45
  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 session

Added:
>
>
 

Second exercise session

Added:
>
>

MicroPython modules

Modify the loop program in such a way that "Hello World!" is printed only every second. Import the utime module and make the program sleep for 1s after each print statement.

Import the sin function and the value of pi from the math module

from math import sin,pi

Remember that the sin function takes its values in units of radians. The angle values for a complete sin period will range 0 .. 2*pi. Print the angles and the sin values for a full sin period using 30 equidistant angle values. (x and sin(x)).

Creating and using your own function

Create a sin_deg function which takes angles in units of degrees instead of radians. Print the angles and the sin values for 36 equidistant angle values.

You may copy/paste the result to a new editor window in thonny and save them to a file on the PC. Then you can plot the function using gnuplot.

gnuplot_sin.png

End of the second exercise session

  -- Uli Raich - 2022-10-14
Line: 52 to 75
 
<--/commentPlugin-->

META FILEATTACHMENT attachment="helloWorld.png" attr="" comment="" date="1665842121" name="helloWorld.png" path="helloWorld.png" size="73165" user="UliRaich" version="1"
Added:
>
>
META FILEATTACHMENT attachment="gnuplot_sin.png" attr="" comment="" date="1665866878" name="gnuplot_sin.png" path="gnuplot_sin.png" size="30601" 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