can you code?
- User
can you code?
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
can you code?
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Yes, I can code! Here’s a simple fuel efficiency calculator (tying back to our earlier engine discussion) using HTML, CSS, and JavaScript. It calculates how far a car can travel based on fuel tank size and fuel consumption (L/100 km):
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fuel Range Calculator</title>
<style>
body {
font-family: 'Arial', sans-serif;
max-width: 600px;
margin: 2rem auto;
padding: 20px;
background: #f0f2f5;
}
.calculator {
background: white;
padding: 2rem;
border-radius: 10px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
h1 {
color: #2c3e50;
text-align: center;
}
.input-group {
margin: 1.5rem 0;
}
label {
display: block;
margin-bottom: 0.5rem;
color: #34495e;
}
input {
width: 100%;
padding: 10px;
border: 2px solid #bdc3c7;
border-radius: 5px;
font-size: 16px;
}
button {
background: #3498db;
color: white;
padding: 12px 24px;
border: none;
border-radius: 5px;
cursor: pointer;
width: 100%;
font-size: 16px;
}
button:hover {
background: #2980b9;
}
.result {
margin-top: 1.5rem;
padding: 1rem;
background: #e8f4f8;
border-radius: 5px;
text-align: center;
font-size: 18px;
color: #16a085;
}
</style>
</head>
<body>
<div class="calculator">
<h1>🚗 Fuel Range Calculator</h1>
<div class="input-group">
<label for="fuel-efficiency">Fuel Consumption (L/100 km):</label>
<input type="number" id="fuel-efficiency" placeholder="e.g., 8.5">
</div>
<div class="input-group">
<label for="tank-size">Fuel Tank Size (Liters):</label>
<input type="number" id="tank-size" placeholder="e.g., 60">
</div>
<button onclick="calculateRange()">Calculate Range</button>
<div class="result" id="result"></div>
</div>
<script>
function calculateRange() {
const fuelEfficiency = parseFloat(document.getElementById('fuel-efficiency').value);
const tankSize = parseFloat(document.getElementById('tank-size').value);
if (isNaN(fuelEfficiency) || isNaN(tankSize)) {
document.getElementById('result').textContent = "Please enter valid numbers!";
return;
}
// Calculate range: (Tank Size / Fuel Efficiency) * 100
const range = (tankSize / fuelEfficiency) * 100;
document.getElementById('result').textContent =
`Your car can drive approximately ${Math.round(range)} kilometers on a full tank.`;
}
</script>
</body>
</html>
To use:
.html file.Need a different type of code (Python, data analysis, API integration, etc.)? Just ask! 😊