Breadboard to Behaviour: Arduino Practice for Quezon City Learners
Quezon City families exploring hardware need safe, clear pathways. Simulators first; kits optional. Enquire +92 322 4217059. No invented QC lab.
An Arduino robotics and electronic sensors course for Quezon City guides students through breadboard wiring, ultrasonic sensing, servo drivers and introductory control code—simulators first, optional kits under supervision.

In programming, unexpected user inputs or runtime conditions can easily cause an application to fail. Without error handling, Python halts execution and outputs system tracebacks that can disrupt the user experience.
To make programs resilient, Python provides a four-part exception-handling architecture:
Consider a simple script that asks a user for a number, converts that input into an integer, and calculates the division 10 / number:
# Suspect code vulnerable to user input errors
user_input = input("Enter a number: ")
number = int(user_input)
result = 10 / number
print("Result:", result)
Testing this code across different user inputs demonstrates how unhandled errors arise:
ZeroDivisionError and terminates execution.int() to fail, raising a ValueError because non-numeric characters cannot be parsed into integers.To prevent crashes, place suspect operations inside a try block and attach targeted except blocks for each anticipated error type. You can also include a generalized fallback block using except Exception as e: to catch unforeseen errors as an object e without breaking the program:
try:
# Attempting the input conversion and division
user_input = input("Enter a number: ")
number = int(user_input)
result = 10 / number
print("Result:", result)
# 1. Handling division by zero
except ZeroDivisionError:
print("You cannot divide a number by zero.")
# 2. Handling non-numeric inputs
except ValueError:
print("That is not a number.")
# 3. Catch-all for any other unanticipated exceptions
except Exception as e:
print("An unexpected error occurred:", e)
except Exception as e:, printing a controlled error message rather than crashing.To build complete control flow into your error handling, Python allows pairing try and except with else and finally:
try:
print("Running code...")
# Clean calculation that does not raise any exception
number = 5
result = 10 / number
print("Calculation successful:", result)
except Exception:
print("An error occurred.")
else:
# Executes ONLY if the try block completed with zero errors
print("No errors found.")
finally:
# ALWAYS executes in all scenarios
print("Done.")
Console Output:
Running code...
Calculation successful: 2.0
No errors found.
Done.
| Keyword | Execution Condition | Typical Purpose |
|---|---|---|
try |
Always executed first | Encloses suspect code that could potentially fail at runtime. |
except |
Runs only if an error occurs inside try | Catches specific exception types and performs graceful recovery. |
else |
Executes only if NO error occurs inside try | Runs follow-up operations that depend on the try block succeeding. |
finally |
Always executes in every case | Performs mandatory cleanup actions (e.g., closing files, releasing resources). |
try contains the suspect code block that you want Python to attempt running. except executes only if an exception is raised inside the try block, catching the error and displaying a controlled recovery message rather than crashing. else executes only when the try block runs successfully with zero errors. finally executes unconditionally in all scenarios, regardless of whether an exception occurred, was handled, or the code ran cleanly.
If a user inputs 0, dividing any number by zero is mathematically undefined, causing Python to raise a ZeroDivisionError. If a user inputs a non-numeric letter (such as 'k'), the int() function cannot convert the string into an integer, raising a ValueError. Wrapping these operations in targeted except ZeroDivisionError: and except ValueError: blocks intercepts each specific failure and displays a friendly notice (e.g., "You cannot divide a number by zero" or "That is not a number") without halting the program.
The finally block always executes in every situation—whether the try block succeeded, an exception occurred and was caught, or an unanticipated error arose. It is used for mandatory concluding operations and resource cleanup, ensuring that tasks such as releasing system locks, closing open database connections, or finalizing file states run reliably before the program moves forward.
mBlock Coding for Kids on Udemy.
Disclosure: This page contains affiliate links. We may earn from qualifying purchases at no extra cost to you. Links are intended for parents and educators, not as marketing directed at young children.
Quezon City families exploring hardware need safe, clear pathways. Simulators first; kits optional. Enquire +92 322 4217059. No invented QC lab.
Students master breadboard circuit wiring, microcontroller programming, ultrasonic distance sensors, servo motor drivers, and basic C++ syntax. Consequently, Quezon City learners gain practical hardware engineering experience suitable for school science fairs and STEM competitions.
No prior experience is required! Our step-by-step curriculum starts from the basics of electric current and logic switches before advancing into complete sensor-guided robot builds.
Simply send a quick message to our mentor team via WhatsApp with your child’s age and current experience level to claim a free 1-on-1 trial session.