Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
Added: | ||||||||
> > |
Exercises for session1: Introduction to IoT and PythonExercise 1:
Exercise 2:Write a program that checks if a number is a prime number. It will either print that it found a prime number or give a valid divisor. Get the number to be tested again from the command line argument as in exercise 1Exercise 3:Modify the above programs into functions that can be called from a main program and write this main program into the same file (Test if name is “__main__” to be able to run the program). Then write a main program in a separate file and import the module into your main program. Call the function in the module Do the same thing for the prime exampleExercise 4:Add a module with a function calculating the factorial of a number: factorial(n) = 1*2*3*4… *nExercise 5:Finally put the fibonacci, the factorial and the prime module into a packet. How do you have to import and call the functions now? If the number if iterations is smaller than 1, raise a ValueErrorExercise 6:Convert the packet with the 3 math functions into a class with the methods:
Exercise 7:Write a callback function printing “Hello” and a program with an endless main loop which calls the callback function once every 2 s. -- Uli Raich - 2019-05-27Comments |