Lesson 11

Instant Challenges IC1. Get 2 integers and multiply Get two integers from user and print the product of the two numbers. Enter the first number: 3 Enter the second number 2: 5 Result: 15 IC2. Get 2 decimal values and multiply IC1 will fail, if you enter a decimal...

Lesson 5

In the previous lesson, you leaned about building a LED circuit and controlling it from your python code. We even made the LED blink. Python Functions You can build your own functions and call it from multiple places. Breaking down into functions, improve the...

lesson 4

Connecting LED   Turn on a LED import RPi.GPIO as GPIO import time ledPin=40 GPIO.setmode(GPIO.BOARD) GPIO.setup(ledPin, GPIO.OUT) GPIO.output(ledPin, GPIO.HIGH) time.sleep(5) GPIO.output(ledPin, GPIO.LOW) GPIO.cleanup() Blink an LED 20 times import RPi.GPIO as...

Lesson 3

List As the name suggests, a list stores a collection of similar data types. List allow duplicate values. fruits = ['orange', 'apple', 'pear', 'apple', 'banana'] #adds 'kiwi' to the end of the list fruits.append('kiwi') print(fruits) print(len(fruits)) #prints 6 which...

Lesson 2

Programming in Python Saving code to py file So far you have been typing code directly in the Python console. You would have lost all the commands you wrote on you previous session. A better approach will be to save your code into a file with an extension of .py, so...