Build Your Own AI Assistant Part 1 - Creating the Assistant
116820 Views
Is the new Raspberry Pi AI Kit better than Google Coral?
114678 Views
Control Arduino with Python using Firmata / PyFirmata
87081 Views
How to Map with LiDAR - using a Raspberry Pi Zero 2W, RPLidar and Rviz
57314 Views
Creating a Supercomputer with a Raspberry Pi 5 Cluster and Docker Swarm!
53588 Views
Node-Red Automation, MQTT, NodeMCU & MicroPython
52067 Views
LidarBot
Snaszy NAS a 3D printed NAS for Raspberry Pi
Waveshare CM5 boards
The Best Arduino Robot for Beginners
SMARS Lab upgrade with PyCharm
Chicken Nugget Piano
Mini-Rack 3D Design Tutorial
0h 20m
Using the Raspberry Pi Pico's Built-in Temperature Sensor
0h 24m
Getting Started with SQL
0h 32m
Introduction to the Linux Command Line on Raspberry Pi OS
0h 42m
How to install MicroPython
0h 8m
Wall Drawing Robot Tutorial
0h 22m
Learn Linux from the basics to advanced topics.
Learn how to use a Raspberry Pi Pico
Learn MicroPython the best language for MicroControllers
Learn Docker, the leading containerization platform. Docker is used to build, ship, and run applications in a consistent and reliable manner, making it a popular choice for DevOps and cloud-native development.
Learn how to build SMARS robots, starting with the 3D Printing the model, Designing SMARS and Programming SMARS
Learn how to build robots, starting with the basics, then move on to learning Python and MicroPython for microcontrollers, finally learn how to make things with Fusion 360.
Learn Python, the most popular programming language in the world. Python is used in many different areas, including Web Development, Data Science, Machine Learning, Robotics and more.
Learn how to create robots in 3D, using Fusion 360 and FreeCAD. The models can be printed out using a 3d printer and then assembled into a physical robot.
Learn how to create Databases in Python, with SQLite3 and Redis.
KevsRobots Learning Platform
60% Percent Complete
By Kevin McAleer, 5 Minutes
Programs often need to work with numbers and text, adding and subtracting, asking questions and processing answers.
MicroPython is able to label different types of values so that it can make different commands available to us.
The different types of values are listed below:
List of MicroPython data types
str
int
float
complex
list
tuple
dict
set
frozenset
bool
bytes
bytearray
memoryview
NoneType
List of common MicroPython data types with examples
1
2
3
4
-500
1000
3.14
-2.5
1.66666
'hello world'
'my name is Kevin'
[‘cat’,’dog’,’fish’,’gecko’],
[1,2,3,5,8,13,21]
{‘name’:’Kevin’, ‘address’:’UK’, ‘age’:45}
("fish",1,2,3,)
object
'Cat()'
byte
255
'0xFF'
'0b11111111'
Note The more complex data types have been excluded from this list. We’ll look at them in more detail in later modules.
When we assign a value to a variable, it is said to have the a type. e.g.
a = 1 b = 2.1 c = "hello"
In this example a contains the value 1 and is of type integer, b contains the value 2.1 and is of type float (because it has a decimal point), and c contains hello and is of type string because it contains a text wrapped inside some speech marks.
a
integer
b
2.1
c
hello
string
Implied Types In other languages, such as C/C++ you will need to tell the compiler what kind of datatype a variable is before it is used. This is known as a strongly typed language; it helps the compiler allocate the correct amount of memory for the variable before it is used. C++ Example int a; // tells the compiler that 'a' is an integer float b; // tells the compiler that 'b' is a floating point number a = 1; b = 2.3; In Python and MicroPython you do not need to assign a type to a variable, Python is smart enough to figure this out by the value being assigned to it. This is known as weakly typed language. The trade off is that Python looks cleaner to read and doesn’t need data types to be assigned before they’re used, however this can lead to confusion if another type of value is expected or assigned to a variable of a differnet type. MicroPython Example a = 1 # python knows that 1 is an integer value so 'a' becomes an 'int' type b = 2.3 # python knows that 2.3 is a floating point value so 'b' becomes a 'float' type
In other languages, such as C/C++ you will need to tell the compiler what kind of datatype a variable is before it is used. This is known as a strongly typed language; it helps the compiler allocate the correct amount of memory for the variable before it is used.
C/C++
strongly typed
int a; // tells the compiler that 'a' is an integer float b; // tells the compiler that 'b' is a floating point number a = 1; b = 2.3;
In Python and MicroPython you do not need to assign a type to a variable, Python is smart enough to figure this out by the value being assigned to it. This is known as weakly typed language. The trade off is that Python looks cleaner to read and doesn’t need data types to be assigned before they’re used, however this can lead to confusion if another type of value is expected or assigned to a variable of a differnet type.
Python
MicroPython
weakly typed
a = 1 # python knows that 1 is an integer value so 'a' becomes an 'int' type b = 2.3 # python knows that 2.3 is a floating point value so 'b' becomes a 'float' type
George Boole the Father of Boolean Logic English mathematician and logician George Boole was the author of The Laws of Thought (1854) which documents the algebra of logic. He founded the idea that logic can be expressed in a series of symbols that show an output of True or False given a set of inputs. These can be expressed as Truth Tables, and is now commonly called Boolean Logic, which is what all modern computing is based upon. Example Truth Table ‘AND’ Logic input a input b output x False False False True False False True True True An AND logic gate has two inputs; a and b and one output x. The table shows each of the possible state the inputs and the outputs can be in. With AND gates both inputs need to be True for the output to be True. This is used a lot in graphics processing too. We will look at logic operators in MicroPython in the Operators lesson.
English mathematician and logician George Boole was the author of The Laws of Thought (1854) which documents the algebra of logic. He founded the idea that logic can be expressed in a series of symbols that show an output of True or False given a set of inputs. These can be expressed as Truth Tables, and is now commonly called Boolean Logic, which is what all modern computing is based upon.
The Laws of Thought
True
False
Truth Tables
Boolean Logic
‘AND’ Logic
An AND logic gate has two inputs; a and b and one output x. The table shows each of the possible state the inputs and the outputs can be in. With AND gates both inputs need to be True for the output to be True. This is used a lot in graphics processing too.
AND
x
We will look at logic operators in MicroPython in the Operators lesson.
< Previous Next >