Multilingual Code Examples
Python (.py)
def greet(name: str) -> str:
return f"Hello, {name}!"
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)
function calculateArea(radius) {
return Math.PI * radius * radius;
}
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)
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)
<!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>
body {
font-family: Arial, sans-serif;
line-height: 1.6;
color: #333;
}
.highlight {
background-color: #ffff00;
padding: 5px;
}
JSON (.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"]
}