Introduction to Programing and Problem Solving Techniques part 1
🕰️1. Short History
Ada Lovelace (1842) – first computer programmer. She wrote the first algorithm.
Joseph Jacquard (1801) – invented the loom that used changeable punch cards
for operation control (early idea of programming).
Herman Hollerith (1889) – Electric Tabulating System, used punched cards
(Hollerith Cards) for data → founded IBM. 1906 developed plug board or control
panel
Atanasoff-Berry Computer (1937) – first electronic digital computer, designed to
solve linear equations, not programmable, used binary arithmetic, regenerative
memory, parallel processing, separate memory.
Colossus (WWII) – first programmable computer (to break German codes).
Grace Murray Hopper (1947) – found the first “computer bug” trapped in Mark II
Alken Relay Calculator (literal nga moth 🦋).
EDSAC (Electronic Delay Storage Automatic Calculator) – the first practical
stored-program electronic computer. On May 6,1949 ran its first program—
calculate a table of sqyares and a list of prime numbers.
FORTRAN (1954) – first high-level programming language. Invented by John
Backus of IBM, and released commercially in 1957.
Spacewar! (1961) – first computer game. Programmed by Steve Russel, took
roughly 200 man-hours to complete.
Fred Cohen (1983) – showed the first computer virus through the use of floppy
disk, the program was benign meant only to prove that it was possible.
💻 2. Computer Basics
Hardware – physical parts (CPU, RAM, mouse, monitor).
o Input (Keyboard, Mouse)
o System Unit
Random Access Memory (RAM)
Central Processing Unit (CPU)
Software – instructions/programs (ang nagasulti sa computer unsa buhaton). A
set of instructions is called program.
CPU (Processor) – brain of the computer. Retrieves instruction from memory and
executes them.
Memory (RAM) – temporary storage, Volatile (mawala kung patay ang
computer). Stores intermediate and final results of processing. Memory unit is an
ordered sequence of bytes, each holds eight bits. Program instructions are
brought to memory before executing.
Storage – non-volatile or permanent (hard drive, USB, SSD). Programs and data
on storages are moved to memory before executing/when the computer uses
them
Computer Language – Binary (0 and 1) – language sa computer. Everything is
stored as 0s and 1s. Encoding Schemes;
o Numeric Data – encoded as binary numbers
o Non-Numeric Data – encoded as binary numbers using representative
code
ASCII – 1 byte per character
Unicode – 2 bytes per character
Programming Languages – dependent language of machine and independent
used by human, with categories for clarification;
o Machine Language – natural language of a computer in the form of binary
code, any languages must be translated down to this level for the
computer to understand
o Assembly Language – english-like abbreviations used for operations, uses
Assembler to convert assembly language programs into machine code
o High Level Language – english-like and easy to learn and program (like
Java, C, C++, FORTRAN, Visual Basic, Pascal)
Compiling Source Code – a program written in a high-level language is called
source programs (source code). A program called compiler is used to translate
the source program into machine language program called an object program.
o Source File → Compiler → Object File → Linker → Executable File
Programming – creation of an ordered set of instructions to solve a problem with
a computer, only about 100-instructions that the computer understands.
Programming Fundamentals;
o Sequential Processing – list of ordered instructions
o Conditional Execution – uses (Ifs)
o Repetitions – looping / repeating
o Stepwise Refinement / Too-Down Design – breaking things into smaller
pieces
o Calling Methods / Functions / Procedures / Subroutines – calling a
segment of code located elsewhere, reuse of previously coded code
segment
Methods of Programming
o Procedural – defining set of steps to transform inputs into outputs,
translating steps into code, constructed as set of procedures (each is a set
of instructions)
o Object-Oriented – defining/utilizing objects to represent real-world entities
that work together to solve problem. Basic O-O Programming
Components;
Class
Object / Instances
Properties
Methods
Program Solving Techniques – process of defining a problem, search relevant
information and resources about the problem, discovering, designing, and
evaluating solutions for further opportunities
o Polya’s 4 steps of problem solving
U – understand the problem (identify inputs, outputs, process) read
the problem statement
D – device a good plan to solve (algorithm, flowchart, psuedocode)
decide how to solve the problem
I – implement the plan, program the code
E – evaluate the solution (run the code, check results, look for new
solutions) test the solution
Introduction to Programming and Problem Solving Techniques part 2
🔢 3. Algorithms
- a list of clear steps to solve a problem.
Properties (Donald Ervin Knuth’s 5):
1. Finiteness – must end.
2. Definiteness – klaro ang steps.
3. Input – start values.
4. Output – results.
5. Effectiveness – must actually work.
🔄 4. Flowcharts
Flowchart = drawing that shows the steps of an algorithm.
Building Blocks / Symbols:
Terminal (Oval) – Start/Stop.
Process (Rectangle) – Process/Action.
Decision (Diamond) – Decision (Yes/No).
Input/Output (Parallelogram) – Input/Output.
Flowline (Arrowhead) – flow/direction.
On-Page Connector (Circle) – represented by small circle with a letter inside
Off-Page Connector (naka baliktad nga Balay) – represented as a Home-
plate shape pentagon
Advantages of using Flowchart:
✔ Communication - Easy to explain.
✔ Effective Analysis - Helps analyze problems.
✔ Documentation for Programs / System - Useful for documentation.
✔ Efficient Program Maintenance – needs maintenance from time to time, easier with
flowchart.
✔ Coding of the Program – Makes coding easier.
Limitations:
✘ Complexity of Logic – complex logic programs becomes complicated flowchart and
tends to oversimplify a process.
✘ Alteration and Modifications in Logic – will require redrawing.
✘ Reproduction – Cannot type symbols easily.
Introduction to Python Programming
🔹 Python Basics
- Popular programming language known for simplicity, versatility, and
efficiency.
- Creator: Guido van Rossum developed in the late 1980s (1991 release,
hobby project, named after Monty Python comedy group).
🔹 IDE Setup
PC IDEs: PyCharm (full-featured), VS Code (lightweight + extensions), IDLE
(default).
Browser IDEs: Programiz, Online Python, Google Colab.
Mobile IDEs: Pydroid (Android), Pythonista (iOS).
🔹 Data Types
Int – (integers) whole numbers (5, -10).
Float – (floating-point numbers / decimals ) decimal numbers (3.14).
Str – (strings) text (“Hello”).
Bool – (booleans) True/False.
🔹 Variables
- No need to declare type explicitly (dynamically typed).
Example:
X = 5; name = “Alice”; is_active = True
🔹 Operators
- Used to perform operations on variables
Assignment: (=)
- Used to assign a value to a variable
Arithmetic:
- Used to perform basic arithmetic
rsum - Addition (+) → x + y
rdiff - Subtraction (-) → x - y
rprod - Multiplication (*) → x * y
rquotient - Division (/) → x / y
remainder - Modulus (%) → x % y
power - Exponentiation (**) → x ** y
floorquot - Floor Division (//) → x // y
Example:
A = 10; b = 5; print(a + b) # 15
print(“Sum is “ + str(rsum))
print(“Sum is “, rsum)
🔹 Expressions & Statements
• Expression: Produces a value → 2 + 3 * 5.
• Statement: Executes an action → print(result).
🔹 Print Statements
- Basic: print(“Hello”) → Hello
- Multiple items: print(“Sum of”, 3, “and”, 5, “is”, 8) → Sum of 3 and 5 is 8
- End parameter: print(“Hello”, end=” “) “second line” print(“World!”) → keeps
text on same line → Hello World!
- With variables: print(“Name:”, name) → Name: Anthony
- F-strings: print(f”My name is {name} and I am {age} years old.”) → My name
is Anthony and I am 21 years old.
🔹 Comments
- Single-line: # This is a comment
- Multi-line: “”” This spans multiple lines “””
- Purpose: Improves readability, maintenance, and teamwork. Will not be
printed
🔹 Operator Precedence
- Follows PEMDAS (Parentheses, Exponents, Multiplication/Division,
Addition/Subtraction). But in the coding, it reads left to right, so if the problem
is 3/5-2*19+3, then it will operate division first, then multiplication, then
subtraction, then the addition.
🔹 User Input
- Basic input:
Name = input(“Enter name: “)
- Convert input:
Age = int(input(“Enter age: “))
🔹 Mnemonic Variable Naming
- Use meaningful names (student_name, total_score).
- Avoid unclear names (x, y) unless context is obvious.