Computers, Programming, and Cognitive Science

Course Curriculum and Academic Grading Structure

  • Course Overview: Basic Programming covers the foundational intersections of computer programming, algorithm design, and cognitive science, progressing from theoretical pseudocode models to practical implementation in Python.

  • Instructional Team:

    • Bogdan Cristescu

    • Adian Apostu

  • Assessment and Grading Breakdown:

    • Quiz 1: 25%25\% of the final grade (administered after Lesson 7).

    • Quiz 2: 25%25\% of the final grade (administered after Lesson 12).

    • Laboratory Assignments: 20%20\% of the final grade.

    • Final Examination: 30%30\% of the final grade.

  • Fourteen-Lesson Curriculum Schedule:

    • Lesson 1: Computers, Programming, and Cognitive Science: From pseudocode to programming languages.

    • Lesson 2: Variables in Python, basic calculus, standard math library utilization, and introspective built-in functions including type() and help().

    • Lesson 3: Matrix operations and linear data handling utilizing the numpy library.

    • Lesson 4: Strings and comprehensive string manipulation techniques.

    • Lesson 5: Branching and decision structures: Logical operators, if statements, and nested conditional logic.

    • Lesson 6: Advanced branching and loop structures: for and while iterative constructs.

    • Lesson 7: Linear collections: Lists and tuples (concludes with Quiz 1 at 25%25\%).

    • Lesson 8: Associative collections: Dictionaries and JSON object construction.

    • Lesson 9: Persistent data storage: File handling, reading, and writing workflows.

    • Lesson 10: Dataframe analysis and statistical visualization utilizing pandas and matplotlib.

    • Lesson 11: Modular software architecture: Function definition and scope.

    • Lesson 12: Recursive programming paradigms (concludes with Quiz 2 at 25%25\%).

    • Lesson 13: Object-Oriented Programming (OOP) fundamentals: Encapsulation, inheritance, and polymorphism.

    • Lesson 14: Advanced OOP concepts, robust error and exception handling, and industry-standard programming best practices.

Cognitive Science and the Necessity of Computation

  • Definition of Cognitive Science: Cognitive science represents the formal interdisciplinary study of the mind and the nature of intelligence, synthesizing theoretical frameworks across multiple traditional fields (Pleh C., Gurova L., 2013).

  • Computational Synthesis and Artificial Intelligence:

    • The central question guiding computational cognitive science asks: What mechanisms emerge when an attempt is made to recreate mental experiences and cognitive functions within synthetic machines?

    • This inquiry directly forms the foundation of Artificial Intelligence (AI).

  • Interdisciplinary Topology (Gardner's Hexagon):

    • The interrelationships among the constituent disciplines of cognitive science are formalized through Gardner's Hexagon, illustrating varying strengths of interdisciplinary collaboration.

    • Unbroken Lines: Represent strong, established interdisciplinary ties.

    • Broken Lines: Represent weaker or emerging interdisciplinary ties.

    • Constituent Disciplines:

      • Philosophy

      • Psychology

      • Linguistics

      • Anthropology

      • Neuroscience

      • Artificial Intelligence


Gardner's Hexagon of Cognitive Sciences
  • Interdisciplinary Ties within Gardner's Hexagon:

    • Strong ties (solid lines): Philosophy to Psychology; Philosophy to Linguistics; Psychology to Artificial Intelligence; Psychology to Linguistics; Linguistics to Artificial Intelligence; Neuroscience to Psychology; Neuroscience to Artificial Intelligence; Neuroscience to Linguistics; Anthropology to Linguistics.

    • Weak ties (dashed lines): Philosophy to Neuroscience; Philosophy to Artificial Intelligence; Philosophy to Anthropology; Psychology to Anthropology; Artificial Intelligence to Anthropology; Neuroscience to Anthropology.

Applied Machine Learning and Cognitive Data Science

  • Electroencephalogram (EEG) Analysis via Machine Learning:

    • Computational tools are engineered to record, clean, process, and classify neuroelectrical signals to diagnose functional neural abnormalities, cognitive states, and neurological events.


EEG Signal Processing and Machine Learning Pipeline
  • Stages of the EEG Computational Pipeline:

    • Data Acquisition: Capturing multichannel continuous voltage fluctuations via scalp electrodes.

    • Data Pre-Processing: Amplification, frequency filtering (bandpass/notch), artifact removal (suppressing ocular, cardiac, and muscular artifacts), and analog-to-digital digitization.

    • EEG Montage: Spatial configuration and topographical channel mapping displayed across standard electrode distributions.

    • Feature Extraction: Quantitative parameter derivation across three key domains:

      • Spectral features: Frequency-band power distributions (delta, theta, alpha, beta, gamma).

      • Temporal features: Time-series waveform characteristics, latency, and amplitude changes.

      • Pattern features: Spatial-temporal morphology and distinct waveform synchronization.

    • Machine Learning Classifiers: Deployment of predictive statistical modeling algorithms, including:

      • Bayesian classifiers

      • Random Forest ensembles

      • Artificial Neural Networks (ANN)

      • Support Vector Machines (SVM)

      • Decision Trees

    • Prediction and Output: Automated data labeling, discrete cognitive event recognition, and clinical seizure detection.

  • Behavioral Analysis and Affective Computing:

    • Multimodal emotion detection: Synchronizing audio, facial micro-expressions, and biometric feeds to interpret human affective states.

    • Automated veracity assessment (computational lie detection).

  • Neural Network Modeling: Creating algorithmic architectures mirroring biological neuron dynamics to simulate cognitive tasks.

  • Sensory AI Paradigms:

    • Visual Modality: Computer Vision for visual cortex simulation, scene understanding, and object recognition.

    • Linguistic Modality: Natural Language Processing (NLP) and Natural Language Understanding (NLU) for syntactic and semantic modeling.

    • Auditory Modality: Automatic speech recognition, phoneme decoding, and general environmental sound recognition.

    • Olfactory Modality: Chemical sensor arrays coupled with neural pattern matchers (Artificial Olfaction / AI Nose, e.g., open-source implementations hosted at https://github.com/kartben/artificial-nose).

  • Data Science Pipeline: Ingestion, wrangling, statistical exploratory analysis, and hypothesis validation across large cognitive datasets.

Algorithmic Representation: Pseudocode Foundations

  • Definition: Pseudocode is an informal high-level description of an algorithm that outlines the operational flow of a program while omitting system-level syntax, memory management, and compilation details.

  • Functional Characteristics:

    • Cannot be directly compiled or executed by hardware.

    • Written using concise, natural language statements and mathematical syntax.

    • Serves as an intermediate bridge between human conceptual problem-solving and machine code implementation.

    • Cultivates computational thinking prior to syntax-locked program development.

  • Standard Pseudocode Reserved Keywords:

    • PRINT: Prompts strings, values, or notifications to the standard output display.

    • INPUT: Captures and ingests user-supplied input from the standard input interface.

    • OUTPUT: Emits processed variables or final results to the user interface.

    • WHILE: Initiates a pre-test conditional loop (iteration verified before executing the loop body).

    • FOR: Initiates a deterministic counter-driven loop (bounded iteration).

    • REPEAT – UNTIL: Initiates a post-test conditional loop (iteration verified at the end of the loop block, executing at least once).

    • IF – THEN – ELSE: Implements binary or multi-way selection logic based on a boolean predicate.

  • Syntactic Conventions: Indentation is mandatory to define the scope and hierarchical block boundaries of nested selections or iterations.

Algorithmic Representation: Flowchart Schematics

  • Definition: A flowchart is a standardized, diagrammatic schema that visually maps the step-by-step sequential workflow, logic branches, and data movements of an algorithm.

  • Standardized Flowchart Block Standards:

Shape Name

Graphical Symbol

Operational Function

Terminal

Rounded Rectangle / Capsule

Denotes the explicit entry point (Start) or termination point (End) of a program or modular sub-process.

Input / Output

Parallelogram

Designates data ingestion operations (INPUT) or data presentation operations (OUTPUT / PRINT).

Flowline

Directed Arrow (→\rightarrow)

Defines sequence, execution vector, and direction of control between functional blocks.

Process

Standard Rectangle

Designates an internal action, arithmetic transformation, state mutation, or memory assignment.

Decision

Diamond (Rhombus)

Represents an evaluative conditional test yielding alternate outgoing control paths (e.g., True/False, Yes/No).

Predefined Process

Double-bordered Rectangle

Refers to an external subroutine, function, or modular procedure defined outside the current diagram.

Comment / Annotation

Open Rectangle connected by dashed line

Houses descriptive, non-executable metadata clarifying an operational step.

Database

Cylinder

Indicates structured persistent data store interaction.

Single Document

Rectangle with Waved Base

Represents hard-copy or discrete printable document output.

Multiple Documents

Stacked Rectangles with Waved Base

Represents batches of multi-page or multi-file document records.

  • Practical Flowchart Application (System Fault Isolation):


Troubleshooting Flowchart Example
  • Start State: Problem observed (Lamp doesn't work).

  • First Evaluation (Decision Diamond): Is the lamp plugged in?

    • If No (False\text{False}): Execute process -> Plug in lamp.

    • If Yes (True\text{True}): Advance to second evaluation.

  • Second Evaluation (Decision Diamond): Is the bulb burned out?

    • If Yes (True\text{True}): Execute process -> Replace bulb.

    • If No (False\text{False}): Execute process -> Repair lamp.

Concrete Pseudocode and Flowchart Walkthroughs

  • Case 1: Body Mass Index (BMI) Computation:

    • Mathematical Definition: BMI calculates the ratio of individual mass in kilograms (ww) to the square of height in meters (hh):

BMI=wh2\text{BMI} = \frac{w}{h^2}

  • Sequential Pseudocode:

PRINT "enter your weight"
INPUT weight
PRINT "enter your height"
INPUT height
BMI = weight / (height * height)
PRINT "Your BMI is: "
OUTPUT BMI


BMI Pseudocode and Flowchart
*   *Flowchart Tracing:* 
    *   Terminal: `Start`
    *   Process/Output: `print "enter your weight"`
    *   Input (Parallelogram): `input w`
    *   Process/Output: `print "enter your height"`
    *   Input (Parallelogram): `input h`
    *   Process (Rectangle): `BMI = w / h^2`
    *   Process/Output: `print "Your BMI is: "`
    *   Output (Parallelogram): `output BMI`
    *   Terminal: `End`
  • Case 2: Calendar Day Mapping (Multi-Branch Selection):

    • Target Lookup Mapping:

      • 1→Mon1 \rightarrow \text{Mon}

      • 2→Tues2 \rightarrow \text{Tues}

      • 3→Wed3 \rightarrow \text{Wed}

      • 4→Thu4 \rightarrow \text{Thu}

      • 5→Fri5 \rightarrow \text{Fri}

      • 6→Sat6 \rightarrow \text{Sat}

      • 7→Sun7 \rightarrow \text{Sun}


Print Day Flowchart Implementation
  • Switch-Case Pseudocode Logic:

INPUT date
SWITCH (date) {
    CASE 1:
        OUTPUT "Mon"
        BREAK
    CASE 2:
        OUTPUT "Tues"
        BREAK
    CASE 3:
        OUTPUT "Wed"
        BREAK
    CASE 4:
        OUTPUT "Thu"
        BREAK
    CASE 5:
        OUTPUT "Fri"
        BREAK
    CASE 6:
        OUTPUT "Sat"
        BREAK
    CASE 7:
        OUTPUT "Sun"
        BREAK
    DEFAULT:
        OUTPUT "invalid"
}
*   *Flowchart Bug Identification:* In the procedural flowchart, the input step incorrectly models variable initialization by placing `date` inside an unassigned process box without explicitly executing an input operation; additionally, the evaluation paths from downstream conditions link directly into overlapping output lines rather than unifying through a single collector bus to the terminal `End`.
  • Exercise: Volume of a Sphere Algorithm:

    • Mathematical Formula:

V=43πr3V = \frac{4}{3}\pi r^3

  • Pseudocode Specification:

PRINT "Enter radius r:"
INPUT r
pi = 3.14159265
volume = (4.0 / 3.0) * pi * (r ^ 3)
PRINT "The volume of the sphere is:"
OUTPUT volume
  • Flowchart Flow Structure:

    1. Terminal: Start

    2. Input/Output: Ingest numeric value for radius rr.

    3. Process: Compute intermediate cube r3r^3, multiply by factor 43π\frac{4}{3}\pi, and assign product to variable VV.

    4. Input/Output: Display calculated output variable VV.

    5. Terminal: End

Language Taxonomy and System Alignment

  • Function of Programming Languages: Formalized symbolic linguistic systems designed to translate high-level algorithmic pseudocode into unambiguous, deterministic machine-executable sequences.

  • Task-Specialized Language Ecosystems:

    • Python: Predominant standard for Artificial Intelligence, deep learning, statistical modeling, and data science.

    • R: Specialized language for statistical computing, bioinformatics, and advanced graphical rendering.

    • Java: Enterprise-scale object-oriented systems, high-concurrency environments, and backend web architectures.

    • C++: High-performance, low-latency computing, systems programming, and high-fidelity real-time game development.

    • SQL (Structured Query Language): Declarative data definition, query retrieval, and manipulation in relational database management systems (RDBMS).

  • Cross-Paradigm Utility: Different languages can implement identical algorithmic pseudocode, but their runtime efficiency, memory footprints, and library support dictate contextual selection.

Python Architecture and Design Principles

  • Historical Origins: Created and formally launched in 1991; named as an homage to the British comedy troupe Monty Python.

  • Core Architectural Properties:

    • General-Purpose: Highly expressive, multi-paradigm language capable of handling disparate problems without architectural domain restrictions.

    • Prioritized Readability: Enforces clean, human-readable syntax leveraging syntactic whitespace instead of curly brackets.

    • Interpreted Runtime: Employs an interpretive engine permitting rapid real-time experimentation via interactive shell evaluation, without requiring manual ahead-of-time (AOT) compilation.

    • Modularity: Core runtime maintains a lightweight base, allowing extended features to be integrated via modular software packages ("modules").

  • Pivotal Scientific and Analytical Python Modules:

    • NumPy: Provides optimized high-performance N-dimensional array and matrix arithmetic.

    • Pandas: Supplies heterogeneous data frame tabular structures for exploratory data analytics.

    • Matplotlib / Seaborn: Visual plotting engines for high-resolution 2D and 3D statistical figures.

    • SciPy (Scientific Python): Foundational computational suite containing mathematical, optimization, and signal processing routines (https://www.scipy.org/).

  • Community and Open-Source Infrastructure:

    • Extensive open-source repository sharing via GitHub facilitates collaborative reuse.

    • Collaborative developer resolution and debug knowledgebases provided by platforms such as Stack Overflow.

    • Authoritative language documentation maintained centrally via the Python Software Foundation (https://docs.python.org/3/).

Industry Popularity Metrics and Market Share

  • Language Tracking Indices: Programming language popularity and industry adoption are tracked quantitatively using two primary evaluation indices: the TIOBE Index (measuring search engine frequency) and the PYPL Popularity of Programming Language Index (measuring online tutorial queries).


Top Computer Languages Popularity Chart
  • Comparative Analysis (August 2021 Data):

    • Python holds the dominant global share under the PYPL index (≈30%\approx 30\%), showing a substantial margin over rival languages.

    • In the TIOBE index, traditional compiled languages like C/C++ maintain high baseline enterprise and legacy infrastructure share (≈20%\approx 20\% for C/C++).

  • TIOBE Index Detailed Rankings (September 2021):

Sep 2021 Rank

Sep 2020 Rank

YoY Change

Programming Language

Market Share Rating

Share Change

1

1

—

C

11.83%11.83\%

−4.12%-4.12\%

2

3

↑\uparrow

Python

11.67%11.67\%

+1.20%+1.20\%

3

2

↓\downarrow

Java

11.12%11.12\%

−2.37%-2.37\%

4

4

—

C++

7.13%7.13\%

+0.01%+0.01\%

5

5

—

C#

5.78%5.78\%

+1.20%+1.20\%

6

6

—

Visual Basic

4.62%4.62\%

+0.50%+0.50\%

7

7

—

JavaScript

2.55%2.55\%

+0.01%+0.01\%

8

14

↑\uparrow

Assembly language

2.42%2.42\%

+1.12%+1.12\%

9

8

↓\downarrow

PHP

1.85%1.85\%

−0.64%-0.64\%

10

10

—

SQL

1.80%1.80\%

+0.04%+0.04\%

11

22

↑\uparrow

Classic Visual Basic

1.52%1.52\%

+0.77%+0.77\%

12

17

↑\uparrow

Groovy

1.46%1.46\%

+0.48%+0.48\%

13

15

↑\uparrow

Ruby

1.27%1.27\%

+0.03%+0.03\%

14

11

↓\downarrow

Go

1.13%1.13\%

−0.33%-0.33\%

System Configuration and Installation Protocol

  • Distribution Acquisition: Python 3.9 (specifically 3.9.7 64-bit installer) is downloaded via the official release registry (https://www.python.org/downloads/release/python-397/).


Python Setup Interface
  • Installation Procedure:

    • Execute the downloaded binary setup wizard.

    • Critical Prerequisite Setting: Check the checkbox labeled "Add Python 3.9 to PATH" at the base of the setup prompt. Neglecting this configuration prevents operating system command line terminals from resolving binary calls to the Python interpreter.

    • Select "Install Now" (which installs standard libraries, IDLE development environment, pip package manager, and system documentation to C:\Users\<User>\AppData\Local\Programs\Python\Python39).

  • Installation Verification: Validate environmental system integration by opening the Command Prompt (CMD) and querying the binary version flag:

python --version

Execution Environments: Interactive Shell vs. Script Files

  • Interactive REPL Execution (Read-Eval-Print Loop):

    • Initiated by entering python directly into a shell or launching the Python IDLE (Integrated Development and Learning Environment) Shell.

    • Evaluates statements dynamically in real-time, displaying expression results immediately without explicit print() calls.

    • IDLE Interactive Session Trace:

>>> print("Hello World")
Hello World
>>> first_number = 1 + 1 + 5
>>> print(first_number)
7
>>> second_number = 105 + 10
>>> print(second_number)
115
>>> total = first_number + second_number
>>> print(total)
122
>>> 115 + 7
122
>>> print(115 + 7)
122
  • File-Based Script Execution:

    • Workflow in IDLE:

      1. Open IDLE development window.

      2. Select File →\rightarrow New File to launch an unbuffered code editor buffer.

      3. Compose programmatic logic statements.

      4. Save file to disk with the mandatory .py source file extension.

      5. Execute source script directly by navigating to Run →\rightarrow Run Module, or striking functional hotkey F5.

      6. The resultant terminal session resets and prints outputs into the main IDLE interactive shell window.

    • Executable Script Content:

print("Hello World")
first_number = 1 + 1 + 5
print(first_number)
second_number = 105 + 10
print(second_number)
total = first_number + second_number
print(total)
print(115 + 7)
  • Command Prompt Execution: Scripts are run directly from OS shells by navigating to the working script directory and executing the file name using the registered python interpreter command:

python your_script.py

The Python Execution Model and Internal Runtime Engine

  • Sequential Statement Processing: The interpreter ingests source instructions in a linear top-to-bottom sequence.

  • Intermediate Bytecode Compilation:

    • The interpreter compiles human-readable source syntax into platform-independent intermediate instructions known as bytecode.

    • Scope of Bytecode Caching: The creation of cached bytecode files (e.g., .pyc files) optimizes load and execution speed primarily for imported module packages, rather than standalone top-level execution scripts.

  • Python Virtual Machine (PVM):

    • The bytecode payload is passed directly into the Python Virtual Machine (PVM).

    • The PVM represents the low-level runtime engine of the Python software stack.

    • It functions as an execution loop that systematically iterates through the compiled bytecode instructions, executing them sequentially.

    • The PVM operates as the final execution stage within the integrated Python interpreter abstraction layer, converting program logic into direct machine-level computing interactions.