/
Core Concepts: Logic, algorithms, and error handling.
Flowcharts:
Visual representation of a sequence in processes.
Aid in planning program flow before coding.
Pseudocode:
Simplifies complex logic into plain language; aids in error reduction.
Types of Programming Errors:
Syntax Errors: Issues from incorrect grammar within the code.
Runtime Errors: Problems occurring during program execution.
Logic Errors: Mistakes in the program logic resulting in incorrect outcomes.
Flowchart Definition:
is a visual representation of a process or algorithm that uses symbols to indicate the flow of steps, decisions, and outcomes in a sequential order.
Common Flowchart Symbols:
Flowchart Example
The flowchart below illustrates the process behind adding five numbers:
Key points to remember about flowchart
The rectangle represents any step in the process of a flowchart.
A decision point (the diamond) allows for a branching path where the flow continues based on the decision (e.g., if the answer is "yes," one action is taken, and if "no," a different action is taken).
A loop is a sequence of instructions that is continually repeated until a certain condition is reached.
Repetition or loops in flowcharts are indicated by arrows looping back to a previous decision point (diamond), which controls whether the process repeat
The oval or ellipse shape is used to denote the start and end points of a flowchart.
Main Types of Errors: Syntax errors, runtime errors, logic errors.
Importance of Understanding Errors: Aids in debugging and ensuring intended program function.
Definition: Violations of the rules of a given programming language.
Result: Program fails to compile or interpret correctly.
Examples:
Missing required punctuation or using incorrect keywords.
Forgetting to close a parenthesis or quotation marks.
In languages like C or Java, semicolons are required, and missing one causes a syntax error.
In Python, indentation is part of the syntax, and incorrect indentation leads to a syntax error.
Most programming languages require variables to be declared before use and failing to do so causes a syntax error.
Definition: Errors occurring during program execution, potentially crashing the program.
Result: Program crashes or stops unexpectedly.
Common Examples:
Input mismatch (e.g., letter instead of a number).
Dividing by zero.
Running out of memory.
Memory leaks or infinite loops causing program failures.
Type-safe languages handle type mismatch with syntax errors instead.
Definition: Errors in the algorithm or logic, where the program runs but produces incorrect results.
Result: Harder to detect since the program runs but behaves incorrectly
Common Examples:
Incorrect operations (e.g., dividing instead of multiplying).
Wrong formulas or variables yielding incorrect results.
Infinite loops originating from logical mistakes.
Definition: High-level, informal description of a program focusing on logic without strict syntax.
Benefits:
Allows concentration on program logic rather than syntax details.
Offers easy readability akin to natural language.
Example Logic:
IF spaceship sprite touches asteroid THEN
show explosion sprite
play explosion sound
subtract a life
END IF
IF lives = 0 THEN
stop game
show game over screen
ELSE
restart game
END IF
Definition: Step-by-step instructions designed to solve specific problems.
Importance: Forms the basis of programs and logical processes.
Examples: Making coffee as an analogy for structured problem-solving steps.
Key Step: Clearly define the problem and objectives when designing an algorithm.
Definition: Set of instructions for performing tasks via computer.
Variations:
Computer Language: Includes coding languages with various purposes.
Style Sheet Language: e.g., CSS for document presentation.
Markup Language: e.g., HTML for document structuring.
Programming Paradigm: Different approaches for programming, including:
Procedural Languages: Sequence-focused instruction.
Object-Oriented Languages: Encapsulate data and methods.
Functional Languages: Composed of function applications.
Low-Level Languages: Closer to machine instructions.
High-Level Languages: Closer to natural language; user-friendly.
Bash: Shell scripting for task automation in Unix/Linux.
C: Low-level system programming language.
C#: High-level, human-readable syntax language.
C/C++: Compiled languages for execution.
Assembly and Machine Code: Low-level representations of instructions.
Python: High-level, widely used for data analysis and machine learning due to readability and libraries (e.g., NumPy, TensorFlow).
Haskell: Purely functional programming.
Java: Main language for Android development; also uses Kotlin.
Swift: Primary for iOS applications, designed to replace Objective-C.
JavaScript: Adds interactivity to web pages, essential for front-end development.
PHP: Server-side scripting for dynamic web content.
R: Used in statistics and data science for powerful data analysis.
SQL: Language for database management and querying.