Definition: Errors that occur when the code violates the rules of the programming language's syntax, similar to errors in grammar in a spoken language.
Example: In a Python program with multiple print statements on the same line:
The program will not execute and will generate a message: SyntaxError: invalid syntax
.
Correction needed: Separate print statements onto different lines.
Additional Error: If username
is referenced but not defined, it constitutes a syntax error as well.
Definition: Errors that occur while the program is running, caused by unusual circumstances that the program cannot handle.
Example: Division by zero will cause the program to crash and produce an error message.
Value Error: Occurs when an operation receives an argument of the right type but an inappropriate value. Example: Dividing by zero.
Name Error: Triggered when the program attempts to access a variable that has not been defined.
Type Error: Arises when an operation or function is applied to an object of inappropriate type (e.g., adding a string to an integer).
Logic Error: The program runs without crashing, but it produces incorrect results. Debugging is required to identify and correct these errors.
Example: Calculating a 5% raise incorrectly due to using 5 instead of 0.05, resulting in an erroneous output of 60,000 instead of the expected 10,500.
Definition: The process of identifying and correcting errors (bugs) in the code.
Method: Involves running the program repeatedly, checking output against expected results, and making necessary corrections in the code.
Example: Correcting a logic error by adjusting the variable representation (removing quotes around variable names).
Bits: The lowest unit of data in computing, represented as binary digits (0s and 1s).
Computational Comparison: An early computer's processing capability, which occupied entire rooms, is vastly inferior to modern smartphones, which are far more powerful.
Processor: Executes instructions sequentially, which are ultimately converted into a form that the hardware understands.
Temporary Memory (Volatile): Refers to RAM where programs run and data is temporarily stored.
Permanent Memory (Non-Volatile): Refers to storage drives (SSD, HDD) where data remains stored even when powered off.
Data Representation: All forms of data (videos, images, text) must be converted to binary for storage and processing.
High-Level Languages: Such as Python, C++, and Java, are user-friendly and abstracted from machine code.
Compilers: Convert high-level code into assembly language, which is then translated into machine language (executable code).
Executable Programs: Files (often with .exe extensions) that can be run on a computer after being translated into machine language.