Algorithmic Thinking and Python Programming Basics
Algorithmic Thinking and Problem-Solving Framework
Algorithmic Thinking Concept:
Algorithmic thinking involves breaking down a complex problem into a sequence of clearly defined, logical, step-by-step instructions that can be executed systematically by a computational system.
Problem Analysis: Calculating Distance Between Two Points:
Consider two points located on a two-dimensional Cartesian coordinate system:
Point 1:
Point 2:
The objective is to calculate the Euclidean straight-line distance () separating these two point coordinates.

Mathematical Formulation (Pythagorean Theorem):
To solve for distance, construct a right-angled triangle where the line segment connecting Point 1 and Point 2 forms the hypotenuse ().
The horizontal side length () represents the difference between the x-coordinates:
The vertical side length () represents the difference between the y-coordinates:
The length of hypotenuse () is computed using the Pythagorean formula:

Concrete Worked Example:
Given Point 1 at and Point 2 at , where , , , and :
Calculate horizontal difference :
Calculate vertical difference :
Calculate straight-line distance :

Process Description Methods: Flowcharts and Pseudocode
Three Core Components of Program Design:
Output: The final result or target value required to solve the problem (e.g., the distance value ).
Process: The logical sequence and computational rules used to transform inputs into outputs (e.g., applying the Pythagorean theorem).
Inputs: The explicit data items needed to carry out the process (e.g., coordinate values ).
Flowcharts:
Flowcharts utilize universal graphical symbols to illustrate the exact sequence of operational steps in a program algorithm.
Standard Flowchart Block Definitions:
Start / End: Represented by an oval shape. Indicates where the execution flow begins or terminates.
Process: Represented by a rectangle shape. Denotes internal calculation, assignment, or manipulation steps.
Input / Output: Represented by a parallelogram shape. Specifies reading data into the system or displaying output data.
Flow: Represented by a directional arrow line. Defines the path and direction of program execution flow.




Step-by-Step Flowchart Construction for Distance Computation:
Draw the Start block (oval).
Read input data values sequentially using input blocks (parallelograms):
Read x1,Read y1,Read x2,Read y2.Perform calculations in process blocks (rectangles):
Display output in an output block (parallelogram):
Display c.Draw the End block (oval).
Pseudocode Specification:
Pseudocode is an informal, human-readable outline of a computer algorithm described in structured plain text statements.
Formal Pseudocode Steps for Distance Calculation:
Read
Read
Read
Read
Calculate
Calculate
Calculate
Display
User Prompting and Interactive Program Execution
Definition of User Prompting:
Prompting is the action of displaying descriptive output text to guide, persuade, or remind a user to enter specific required input data into the program.
Incorporating Prompts into Flowcharts and Pseudocode:
Prompting adds dedicated input/output interaction steps before reading each variable.
Updated Pseudocode Sequence with User Prompts:
Prompt the user to enter the x coordinate of point 1
Read
Prompt the user to enter the y coordinate of point 1
Read
Prompt the user to enter the x coordinate of point 2
Read
Prompt the user to enter the y coordinate of point 2
Read
Calculate
Calculate
Calculate
Display

Command-Line Interface Execution Trace:
Execution command:
python Calculate_Distance.pyInteraction sequence:
Please Enter the value for x1: 1Please Enter the value for y1: 5Please Enter the value for x2: 5Please Enter the value for y2: 2Final Output:
The distance between the two points is 5
Python Variables, Naming Conventions, and Data Types
Python Variables and Identifier Rules:
Variables store computational values in memory and are referenced using identifiers (names).
Allowed characters for identifiers: Letters (
a–z,A–Z), digits (0–9), and underscores (_).Identifier Rules:
Must start with a letter or an underscore (
_).Cannot start with a numeric digit.
Identifiers are case-sensitive (e.g.,
Speedis completely distinct fromspeed).Cannot use reserved Python keywords (e.g.,
True,int,for,class).Examples of valid identifiers:
speed,item_1,_pirate,nam3.Variable Assignment: Data is stored in variables using the single equals sign assignment operator (
=): ```python