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
SMARS Lab upgrade with PyCharm
Chicken Nugget Piano
Pi Tray - Mini-rack - Part II
Weather Station Display
Pi 10 Inch Mini-rack
Installing and Using DeepSeek-R1:1.5 on a Raspberry Pi with Docker
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
35% Percent Complete
By Kevin McAleer, 3 Minutes
Python is known for its rich set of libraries and modules which simplifies the coding experience. In this lesson, we will understand what Python libraries and modules are, how to import them, and get a brief look at a few popular libraries.
libraries
modules
math
random
datetime
In Python, a module is a file containing Python code. A library is a collection of modules. They define functions, classes, and variables that you can reuse in your programs.
module
file
library
functions
classes
variables
You can use the import keyword to import a module or a library. Once imported, you can use the dot notation to access the functions, classes, and variables defined in that module.
import
# Importing the math module import math # Using a function from the math module print(math.sqrt(16)) # Prints '4.0'
The math module provides mathematical functions and constants.
import math # Constants print(math.pi) # Prints '3.141592653589793' # Trigonometric functions print(math.sin(math.pi/2)) # Prints '1.0' # Logarithmic functions print(math.log(100, 10)) # Prints '2.0'
The random module provides functions for generating random numbers.
import random # Generate a random float between 0 and 1 print(random.random()) # Generate a random integer between 1 and 10 print(random.randint(1, 10)) # Randomly choose an item from a list print(random.choice(['apple', 'banana', 'cherry']))
The datetime module provides classes for manipulating dates and times.
import datetime # Get the current date and time now = datetime.datetime.now() print(now) # Create a specific date independence_day = datetime.datetime(1776, 7, 4) print(independence_day) # Calculate the difference between two dates delta = now - independence_day print(delta.days)
In this lesson, you’ve learned about Python libraries and modules. You’ve learned how to import them and explored a few popular libraries: math, random, and datetime. Libraries and modules are powerful tools that allow you to leverage existing code and build complex applications more easily.
< Previous Next >