Week 4 Programming Looping and functions, make a buzzer sound with PWM
Fix up Code
We need to fix up the mistake in several programs where the pin reset is wrong to do this
- save basics/variables.py as basics/variables_your_name.py
This is because we are going to update the code and we may lose the work you did otherwise. - In Thonny open any file and go to tools->open system shell
- In the raspberry directory (you may need to change directory) type git pull
Programming
- Conditionals (basics\conditionals.py)
- Looping For, While (basics\looping.py)
- Functions (basics\functions2025)
- Scope of blocks (counter inside function) use of the global keyword.
Pico
- Make a buzzer sound using pwm (pico_code\buzzer.py)
Homework
- Using a while loop add Fibonacci numbers and output their values until the Fibonacci number is greater that 100,000
- Extension homework. Find the largest prime number you can in 1 hr. (Ok to use your watch no need to look up "time" functions)
- Out of interest...
RSA prime numbers used are between 1024 bits long and 2048 bits long which means they are between.... 2^1024 -1 and 2^2048 -1
which for a 1024 bit number the largest number would be (approx)
179 800,000,(300 zeros) or 1.798 E 308
Comments
Post a Comment