Lesson Overview

Programming basics form the foundation of all software development. Before programmers can build advanced applications such as artificial intelligence systems, they must understand the core concepts that allow programs to store data, make decisions, and perform repeated tasks.

These basic programming concepts include:

  • Algorithms
  • Data types
  • Variables
  • Conditional statements
  • Loops
  • Arrays
  • Characters
  • Functions
  • Input and output

Understanding these building blocks allows programmers to create structured programs that solve problems efficiently.

1. Basics of Algorithms

Algorithms are step-by-step instructions used to solve problems or perform tasks in programming. In programming, algorithms are usually written before the actual code is developed so that the logic of the program is clearly defined.

Basic algorithm design focuses on:

  • Identifying the problem
  • Defining the inputs and outputs
  • Creating logical steps to reach a solution
  • Testing the algorithm for accuracy

For example:

Algorithm to calculate the area of a rectangle

Step 1: Input the length
Step 2: Input the width
Step 3: Multiply length by width
Step 4: Display the result

This algorithm clearly shows the steps required to solve the problem.

2. Basic Data Types

Data types define the type of data that a program can store and manipulate. Different types of data require different types of storage and operations.

Some common basic data types include:

Integer

An integer represents whole numbers without decimal points.

Examples:
10, 25, -3

Float (Decimal Numbers)

A float represents numbers that contain decimal points.

Examples:
3.14, 7.5, 10.25

String

A string represents text or characters enclosed within quotation marks.

Examples:

“Hello”
“Artificial Intelligence”

Boolean

A Boolean data type represents logical values.

There are only two possible values:

  • True

  • False

Booleans are commonly used in decision-making within programs.

Character

A character represents a single letter, number, or symbol.

Examples:

‘A’
‘B’
‘1’

Characters are often used when processing text data.

3. Variables in Programming

A variable is a named storage location used to store data in a program.

Variables allow programmers to store information that can change during the execution of a program.

Example:

 
age = 25
name = “John”
temperature = 36.5
 

In this example:

  • age stores a number
  • name stores text
  • temperature stores a decimal value

Variables make programs flexible because their values can change during program execution.

4. Conditional Statements (If Statements)

Conditional statements allow programs to make decisions based on certain conditions.

The most common conditional statements are:

IF Statement

The IF statement executes code only if a condition is true.

Example:

 
if age >= 18:
print(“You are an adult”)
 

IF-ELSE Statement

The IF-ELSE statement allows a program to choose between two possible actions.

Example:

 
if password == “1234”:
print(“Access granted”)
else:
print(“Access denied”)
 

Conditional statements allow programs to respond to different situations.

5. Loops in Programming

Loops allow a program to repeat a set of instructions multiple times. This prevents programmers from writing the same code repeatedly.

The three common types of loops are:

For Loop

A for loop repeats a set of instructions a specific number of times.

Example:

 
for i in range(5):
print(i)
 

While Loop

A while loop repeats instructions as long as a condition remains true.

Example:

 
while number < 10:
print(number)
 

Do-While Loop

A do-while loop executes code at least once before checking the condition.

Some programming languages support this type of loop.

6. Arrays in Programming

An array is a collection of multiple values stored in a single variable.

Arrays allow programs to manage groups of data efficiently.

Example:

 
numbers = [10, 20, 30, 40]
 

In this example:

  • The array contains four numbers
  • Each value is stored in a specific position called an index

Arrays are commonly used in data processing and algorithms.

7. Characters in Programming

Characters represent individual symbols such as letters, numbers, or punctuation marks.

Examples of characters include:

  • ‘A’

  • ‘B’

  • ‘5’

  • ‘@’

Characters are used in text processing, passwords, and data validation.

8. Functions in Programming

A function is a block of code designed to perform a specific task.

Functions help organize programs and allow code to be reused.

Example:

 
def greet():
print(“Hello World”)
 

When the function is called, it executes the instructions inside it.

Functions help make programs easier to read, maintain, and debug.

9. Input and Output in Programming

Programs often need to receive data from users and display results.

Input

Input refers to data entered into a program.

Example:

 
name = input(“Enter your name: “)
 

Output

Output refers to information displayed by the program.

Example:

 
print(“Hello”, name)
 

Input and output allow programs to interact with users.

Lesson Summary

In this lesson, learners explored the basic building blocks of programming. These include algorithms, data types, variables, conditional statements, loops, arrays, characters, functions, and input/output operations.

These concepts form the foundation of all programming languages and are essential for developing software applications, including artificial intelligence systems.

Understanding these fundamentals prepares learners for writing real programs and solving complex computational problems.