Skip to content
Home ยป Notes ยป Basic Coding Concepts

Basic Coding Concepts

  • by

๐Ÿ’ก Introduction

Before creating programs or apps, you need to understand the building blocks of code.
These are the basic concepts that every programming language โ€” Python, Java, C++, or others โ€” is built upon.

In this post, youโ€™ll learn about:

  • Variables
  • Data types
  • Input and output
  • Operators

๐Ÿงฑ 1. Variables

A variable is a container used to store data.
It has a name and a value, and the value can change during program execution.

๐Ÿ’ฌ Think of it like a labeled box where you store something.

Example (Python):

name = "Alex"
age = 20

Here:

  • name is a variable storing text
  • age is a variable storing a number

You can later change their values:

age = 21

๐Ÿ”ข 2. Data Types

Data types define what kind of data a variable can store.

Data TypeDescriptionExample
Integer (int)Whole numbers10, -5
Float (float)Decimal numbers3.14, 2.0
String (str)Text or characters"Hello", 'EduTech'
Boolean (bool)True or FalseTrue, False

๐Ÿ’ก Each language has its own syntax, but the concept is the same.

Example (Java):

int age = 18;
double price = 12.5;
String name = "Alex";
boolean isStudent = true;

โŒจ๏ธ 3. Input and Output

To make programs interactive, we use:

  • Input โ€” get data from the user
  • Output โ€” show results to the user

Example (Python):

name = input("Enter your name: ")
print("Hello, " + name)

๐Ÿ’ก The program waits for you to type your name, then greets you using that input.

Example (C++):

#include <iostream>
using namespace std;

int main() {
    string name;
    cout << "Enter your name: ";
    cin >> name;
    cout << "Hello, " << name;
}

โž• 4. Operators

Operators are symbols that perform operations on variables or values.
They can be arithmetic, comparison, or logical.

๐Ÿ”น Arithmetic Operators

OperatorMeaningExample
+Addition5 + 2 = 7
-Subtraction10 - 3 = 7
*Multiplication4 * 2 = 8
/Division9 / 3 = 3
%Modulus (remainder)10 % 3 = 1

๐Ÿ”น Comparison Operators

Used to compare two values (results in True/False).

OperatorExampleResult
==5 == 5True
!=4 != 5True
>7 > 3True
<2 < 1False

๐Ÿ”น Logical Operators

Used to combine conditions.

OperatorMeaningExample
andTrue if both are truex > 5 and x < 10
orTrue if one is truex > 5 or x < 2
notReverses True/Falsenot(x > 5)

๐Ÿง  Summary

ConceptDescription
VariableStores a value that can change
Data TypeDefines what type of data a variable holds
Input/OutputCommunicates with the user
OperatorsPerform calculations or comparisons