Expanded_IT_Report_Computer_Science_300L
Expanded_IT_Report_Computer_Science_300L
print('Hello, world!')
# List Example
fruits = ['apple', 'banana', 'cherry']
print(fruits[1]) # Output: banana
# Dictionary Example
student = {'name': 'John', 'age': 20}
print(student['name']) # Output: John
# Conditional Statement
age = 18
if age >= 18:
print("You are eligible to vote.")
else:
print("You are not eligible.")
# Grading system
score = int(input("Enter your score: "))
if score >= 70:
grade = 'A'
elif score >= 60:
grade = 'B'
else:
grade = 'C'
print("Your grade is", grade)
Chapter 3: C++ Programming
// Class Example
class Car {
public:
string brand;
void honk() {
cout << "Beep beep!" << endl;
}
};
#include <fstream>
ofstream file("data.txt");
file << "Writing to a file.";
file.close();
try {
int division = 10 / 0;
} catch (ArithmeticException e) {
System.out.println("Cannot divide by zero!");
}
<!DOCTYPE html>
<html>
<head>
<title>My Page</title>
</head>
<body>
<h1>Welcome!</h1>
</body>
</html>
<script>
function greet() {
alert('Hello, user!');
}
</script>
<button onclick="greet()">Click Me</button>