KM-04: Lesson 2 — Programming Basics
Lesson Outcomes
By the end of this lesson, learners will be able to:
- Understand what a programming environment is
- Explain the role of IDEs in software development
- Describe algorithms and their characteristics
- Identify and use different data types
- Understand variables, keywords, and operators
- Apply logical operations and control structures
- Explain loops, arrays, and functions
- Demonstrate basic input and output operations
Lesson Overview
This lesson introduces the core building blocks of programming. It moves from the tools developers use (like IDEs) to the logic behind coding (algorithms), and finally into the practical elements such as variables, loops, and functions.
Think of this lesson as your “starter pack” for writing actual code — this is where things start getting real.
1. Programming Environment
A programming environment is a combination of hardware and software that allows developers to build applications.
Key Points:
- It includes tools for writing, testing, and debugging code
- Developers usually work in an IDE (Integrated Development Environment)
- IDEs provide:
-
-
Code editor
-
Debugging tools
-
Compilation/testing features
-
Examples of IDEs:
- Visual Studio
- NetBeans
- Eclipse
- IntelliJ
💡 In simple terms: it’s your coding workspace — like a digital workshop where everything you need is in one place.
2. Algorithms
An algorithm is a step-by-step procedure used to solve a problem.
Characteristics of an Algorithm:
- Precision – steps are clearly defined
- Finiteness – it must end
- Input – receives data
- Output – produces a result
- Generality – works for different inputs
Why Algorithms Matter:
- They simplify problem-solving
- They are independent of programming languages
- They help with debugging and efficiency
💡 If coding is cooking, algorithms are the recipe.
3. Data Types
A data type defines the kind of data a variable can store.
Common Data Types:
- Integer – whole numbers (e.g., 10)
- Float – decimal numbers (e.g., 3.14)
- String – text (e.g., “Hello”)
- Boolean – true/false
Why Data Types Matter:
- They determine how data is stored and processed
- Prevent errors in programs
- Help with efficient memory use
4. Variables
A variable is a named storage location used to hold data.
Key Concepts:
- Values can change during execution
- Stored in memory
- Declared before use
Example:
💡 Think of variables as labeled containers for your data.
5. Keywords
Keywords are reserved words in programming that have special meanings.
Examples:
-
if,else,while,return,class
⚠️ You cannot use keywords as variable names
6. Logical & Arithmetic Operators
Operators perform operations on data.
Arithmetic Operators:
+(addition)-(subtraction)*(multiplication)/(division)%(modulus)
Relational Operators:
==equal to!=not equal>greater than<less than
💡 These help computers make calculations and comparisons.
7. Logical Operations (Conditionals)
Conditionals allow programs to make decisions.
Example:
print(“Adult”);
}
Types:
-
If
-
If-else
-
Else-if
💡 Programs become “smart” when they can decide what to do.
8. Loops
A loop repeats a block of code until a condition is met.
Types:
- For loop – runs a fixed number of times
- While loop – runs while a condition is true
- Do-while loop – runs at least once
💡 Loops save you from writing the same code 100 times (your future self will thank you).
9. Numbers, Characters, and Arrays
Arrays:
- Store multiple values in one variable
- Same data type
- Accessed using index
Example:
💡 Arrays = organized collections of data
10. Functions
A function is a reusable block of code that performs a task.
Benefits:
- Reusability
- Cleaner code
- Easier debugging
Example:
return a + b;
}
💡 Functions = “do this task for me whenever I ask.”
11. Input and Output Operations
Programs interact with users through:
-
Input → data entered by user
-
Output → results displayed
Example:
print name
✅ Lesson 2 Summary
In this lesson, you learned:
- How programming environments and IDEs work
- How algorithms guide problem-solving
- The role of data types and variables
- How operators and conditionals control logic
- How loops automate repetition
- How arrays store data
- How functions simplify coding
- How input/output enables interaction