Just don’t make it angry
07 November 2022
I made a robot that can see using sound. #shorts
03 November 2022
Best night of his life
12 October 2022
What happens when robots die?
11 October 2022
Pomodoro robot! This is a work in progress but too cute not to share
30 September 2022
Build your own web server using a Raspberry Pi Pico W using Phew.
28 August 2022
Yukon & Omnibot 3000
Omnibot 3000
Pico W Toothbrush
Whats new in Python 3.13a
Maker Faire Rome 2023
WeatherBot
Data Manipulation with Pandas and Numpy
Computer Vision on Raspberry Pi with CVZone
Learn how to program SMARS with Arduino
Build a SMARS Robot in Fusion 360
Python for beginners
Create Databases with Python and SQLite3
KevsRobots Learning Platform
20% Percent Complete
By Kevin McAleer, 2 Minutes
In this lesson, we’ll explore how to control the flow of your Python programs using conditional statements (if, elif, else), loops (for, while), and functions.
if
elif
else
for
while
functions
In Python, we use if, elif (else if), and else to control conditional flows. They help the program to make decisions based on certain conditions.
age = 20 if age < 13: print("You are a kid.") elif age < 20: print("You are a teenager.") else: print("You are an adult.")
Python has two types of loops - for and while.
for i in range(5): print(i)
counter = 0 while counter < 5: print(counter) counter += 1
Functions are reusable pieces of code. They only run when called and can receive parameters and return data.
# Defining a function def greet(name): return f"Hello, {name}!" # Calling a function message = greet("Alice") print(message) # Prints "Hello, Alice!"
In this lesson, you’ve learned about controlling the flow of your Python programs using conditional statements, loops, and functions. Understanding control flow is crucial in writing dynamic and flexible Python programs.
< Previous Next >