Code Laboratory

Side-by-side programming tutorials for beginners.

Python

Lesson 1: Variables & Output

Assign data to variables dynamically without declaring types.

name = "Alice"
print(f"Hello, {name}!")

Lesson 2: Conditionals (If/Else)

Use indentation to structure execution based on boolean logic.

age = 18

if age >= 18:
    print("You are an adult.")
else:
    print("You are a minor.")

Lesson 3: Loops (For & While)

Iterate over ranges or run a block until a condition changes.

# For loop
for i in range(3):
    print(f"Count: {i}")

# While loop
count = 0
while count < 3:
    print(count)
    count += 1

Lesson 4: Functions

Define reusable tasks using the "def" keyword.

def greet(username):
    return f"Welcome back, {username}!"

message = greet("Bob")
print(message)

Lesson 5: Arrays / Lists

Store items in ordered collections that dynamically resize.

fruits = ["apple", "banana", "cherry"]

# Append item
fruits.append("orange")

# Loop through list
for fruit in fruits:
    print(fruit)
C++

Lesson 1: Variables & Output

Explicitly define static types and end lines with semicolons.

#include <iostream>
#include <string>

int main() {
    std::string name = "Alice";
    std::cout << "Hello, " << name << "!" << std::endl;
    return 0;
}

Lesson 2: Conditionals (If/Else)

Enclose evaluation terms inside parentheses and operational tasks inside braces.

#include <iostream>

int main() {
    int age = 18;
    
    if (age >= 18) {
        std::cout << "You are an adult." << std::endl;
    } else {
        std::cout << "You are a minor." << std::endl;
    }
    return 0;
}

Lesson 3: Loops (For & While)

Initialize variables, conditions, and increments explicitly inside structural statements.

#include <iostream>

int main() {
    // For loop
    for (int i = 0; i < 3; i++) {
        std::cout << "Count: " << i << std::endl;
    }

    // While loop
    int count = 0;
    while (count < 3) {
        std::cout << count << std::endl;
        count++;
    }
    return 0;
}

Lesson 4: Functions

Declare signature function return types prior to operational code routines.

#include <iostream>
#include <string>

std::string greet(std::string username) {
    return "Welcome back, " + username + "!";
}

int main() {
    std::string message = greet("Bob");
    std::cout << message << std::endl;
    return 0;
}

Lesson 5: Arrays / Vectors

Utilize size-flexible standard library Vectors instead of basic fixed arrays.

#include <iostream>
#include <vector>
#include <string>

int main() {
    std::vector<std::string> fruits = {"apple", "banana", "cherry"};
    
    // Append item
    fruits.push_back("orange");
    
    // Loop through vector
    for (const std::string& fruit : fruits) {
        std::cout << fruit << std::endl;
    }
    return 0;
}