Multilingual Code Examples

Python (.py)

# example.py
def greet(name: str) -> str:
    return f"Hello, {name}!"

# Different data types
integer_example: int = 42
float_example: float = 3.14
string_example: str = "Python"
boolean_example: bool = True
list_example: list = [1, 2, 3, 4, 5]
dict_example: dict = {"key": "value"}

print(greet("World"))
    

JavaScript (.js)

// script.js
function calculateArea(radius) {
  return Math.PI * radius * radius;
}

// Different data types
let numberExample = 42;
let stringExample = 'JavaScript';
let booleanExample = false;
let arrayExample = [1, 2, 3, 4, 5];
let objectExample = { key: 'value' };

console.log(`Area of circle with radius 5: ${calculateArea(5)}`);
    

SQL (.sql)

-- database.sql
CREATE TABLE users (
    id INT PRIMARY KEY,
    username VARCHAR(50) NOT NULL,
    email VARCHAR(100) UNIQUE NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

INSERT INTO users (id, username, email) VALUES
(1, 'john_doe', 'john@example.com'),
(2, 'jane_smith', 'jane@example.com');

SELECT * FROM users WHERE id = 1;
    

HTML (.html) and CSS (.css)

<!-- index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Sample Page</title>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <h1>Welcome to My Page</h1>
    <p class="highlight">This is a sample paragraph.</p>
</body>
</html>

/* styles.css */
body {
    font-family: Arial, sans-serif;
    line-height: 1.6;
    color: #333;
}

.highlight {
    background-color: #ffff00;
    padding: 5px;
}
    

JSON (.json)

// config.json
{
  "appName": "MyApp",
  "version": "1.0.0",
  "database": {
    "host": "localhost",
    "port": 5432,
    "user": "admin",
    "password": "secret"
  },
  "debug": true,
  "allowedIPs": ["192.168.1.1", "10.0.0.1"]
}