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
55% Percent Complete
By Kevin McAleer, 2 Minutes
Let’s do something more interesting.
We’ll make the Raspberry Pi Pico (or whichever board you are using) ask us a question, then reply back to us.
Type of the program below into your Python Editor
# Variables # name.py print("Please type your name:") name = input() print("Hello", name)
Save the file and then run it by pressing the green run button.
run
The name variable holds the value that it is assigned, and we assigned it by using the = equals sign.
name
=
The function input, is another built-in function that MicroPython provides to get user input from the keyboard and return it to our program.
input
The variable is like a box that we can put things in, in this case a persons name.
We can also store numbers in variables; let’s extend our example and add an extra question
numbers
type:
name = input('hello, please enter your name > ') age = input('please enter your age > ') print('hello', name, 'how does', age, 'feel?')
Note input() only returns text (str) types of data, this means if you try to do any math with the age it will not work in the way you expect. If you want age to be a number you will too to wrap it in the int() type to change it. E.g. age = int(input('please enter your age >')) print('next year you will be', age + 1, 'years old') This is called casting and we’ll look at this in more depth in later modules.
input() only returns text (str) types of data, this means if you try to do any math with the age it will not work in the way you expect.
input()
str
If you want age to be a number you will too to wrap it in the int() type to change it.
age
int()
E.g.
age = int(input('please enter your age >')) print('next year you will be', age + 1, 'years old')
This is called casting and we’ll look at this in more depth in later modules.
casting
We can use variables in maths, for example if we want to find the missing angle in a triangle, and we have the other two angles we can use a formula: 180 - a + b = c
180 - a + b = c
a = 65 b = 42 c = 180 - a + b print('the missing angle is: ', c)
< Previous Next >