Random Code Files
Random Code Files
py
def calculator(a, b, op):
if op == '+':
return a + b
elif op == '-':
return a - b
elif op == '*':
return a * b
elif op == '/':
return a / b if b != 0 else "Cannot divide by zero"
else:
return "Invalid operator"
print(calculator(10, 5, '*'))
hello_world.java
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, world!");
}
}
counter.html
<!DOCTYPE html>
<html>
<head>
<title>Counter</title>
</head>
<body>
<h1 id="count">0</h1>
<button onclick="increment()">+</button>
<script>
let count = 0;
function increment() {
count++;
document.getElementById("count").innerText = count;
}
</script>
</body>
</html>
data.json
{
"name": "Alice",
"age": 30,
"isStudent": false
}
style.css
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
color: #333;
}