Tech Lesson 2:
Basic Programming Concepts

Introduction

In this lesson, we'll learn about four fundamental programming concepts: variables, conditionals, loops, and functions. These concepts form the building blocks of almost every programming language in existence.

1. Variables

Variables are used to store data in a program. Think of them as labeled boxes that can hold different types of information, such as numbers, text, or true/false values.

Exercise: Variables

Declare a variable and assign it a value to see how it is stored:



2. Conditionals

Conditionals allow programs to make decisions. The most common form is the if-else statement, which tells the computer to do one thing if a condition is true, and another if it is false.

Exercise: Logic Check

Enter a number to see if the program classifies it as positive or negative:


3. Loops

Loops allow you to repeat a block of code multiple times without writing it out again. This is useful for tasks like counting, searching through lists, or repeating animations.

Exercise: Repeat Action

How many times should the loop run? (1-100):

4. Functions

Functions are reusable blocks of code that perform specific tasks. Instead of writing the same math or logic repeatedly, you "call" the function whenever you need it.

Exercise: Calculate with Functions

This function calculates the area of a rectangle ($Area = Length \times Width$):

AI Interaction

Need a deeper explanation of loops or variables? Ask our AI assistant:

Back to Lesson 1 Back to Dashboard