0% found this document useful (0 votes)
7 views

Random Code Files

The document contains multiple code snippets in different programming languages including Python for a calculator function, Java for a Hello World program, HTML for a simple counter, JSON data representation, and CSS for styling a webpage. Each snippet serves a distinct purpose: performing arithmetic operations, displaying a greeting, counting user interactions, storing user information, and styling the webpage. Together, they demonstrate basic programming concepts across various languages.

Uploaded by

aribari2452
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Random Code Files

The document contains multiple code snippets in different programming languages including Python for a calculator function, Java for a Hello World program, HTML for a simple counter, JSON data representation, and CSS for styling a webpage. Each snippet serves a distinct purpose: performing arithmetic operations, displaying a greeting, counting user interactions, storing user information, and styling the webpage. Together, they demonstrate basic programming concepts across various languages.

Uploaded by

aribari2452
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

calculator.

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;
}

You might also like