CS Practice Exercises

Python

# Example: Hello, World!
print("Hello, World!")

# Exercise: Simple Addition
def add(a, b):
    return a + b

# Try calling the function with different values
print(add(3, 5))  # Expected output: 8
            

C#

// Example: Hello, World!
using System;

class Program {
    static void Main() {
        Console.WriteLine("Hello, World!");
    }
}

// Exercise: Simple Addition
using System;

class Program {
    static int Add(int a, int b) {
        return a + b;
    }

    static void Main() {
        Console.WriteLine(Add(3, 5));  // Expected output: 8
    }
}
            

Java

// Example: Hello, World!
public class Main {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}

// Exercise: Simple Addition
public class Main {
    public static int add(int a, int b) {
        return a + b;
    }

    public static void main(String[] args) {
        System.out.println(add(3, 5));  // Expected output: 8
    }
}