Spaces:
Running
Running
File size: 31,961 Bytes
1f2c6d9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Learn Java & Python Basics</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
.code-editor {
font-family: 'Courier New', Courier, monospace;
background-color: #2d2d2d;
color: #f8f8f2;
padding: 1rem;
border-radius: 0.5rem;
tab-size: 2;
}
.tab-button {
transition: all 0.2s ease;
}
.tab-button.active {
border-bottom: 3px solid #3b82f6;
font-weight: 600;
}
.exercise-card {
transition: transform 0.2s ease;
}
.exercise-card:hover {
transform: translateY(-2px);
}
.language-icon {
width: 80px;
height: 80px;
}
</style>
</head>
<body class="bg-gray-50 min-h-screen">
<div class="container mx-auto px-4 py-8">
<!-- Header with Theme Image -->
<header class="text-center mb-12 relative">
<div class="absolute inset-0 bg-gradient-to-r from-blue-500 to-purple-600 rounded-2xl opacity-20 h-64"></div>
<div class="relative z-10">
<h1 class="text-5xl font-bold text-gray-800 mb-6 pt-8">Learn Java & Python Basics</h1>
<p class="text-xl text-gray-600 max-w-3xl mx-auto mb-8">
Master the fundamentals of two powerful programming languages through interactive lessons
</p>
<div class="flex justify-center space-x-12 mb-8">
<div class="text-center">
<img src="https://cdn-icons-png.flaticon.com/512/226/226777.png" alt="Java" class="language-icon mx-auto mb-2">
<span class="font-medium text-gray-700">Java</span>
</div>
<div class="text-center">
<img src="https://cdn-icons-png.flaticon.com/512/5968/5968350.png" alt="Python" class="language-icon mx-auto mb-2">
<span class="font-medium text-gray-700">Python</span>
</div>
</div>
</div>
</header>
<!-- Learning Path Navigation -->
<section class="mb-16 bg-white rounded-xl shadow-lg overflow-hidden">
<div class="p-6">
<h2 class="text-2xl font-semibold text-gray-800 mb-6 flex items-center">
<i class="fas fa-road mr-3 text-blue-500"></i>
Learning Path
</h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-8">
<!-- Java Path -->
<div class="border-l-4 border-blue-500 pl-6">
<h3 class="text-xl font-medium text-gray-800 mb-4 flex items-center">
<img src="https://cdn-icons-png.flaticon.com/512/226/226777.png" alt="Java" class="w-6 h-6 mr-2">
Java Fundamentals
</h3>
<ol class="space-y-4">
<li class="flex items-start">
<span class="flex-shrink-0 bg-blue-500 text-white rounded-full w-6 h-6 flex items-center justify-center mr-3">1</span>
<div>
<h4 class="font-medium text-gray-800">Variables & Data Types</h4>
<p class="text-sm text-gray-600">Learn primitive types, declarations, and type casting</p>
</div>
</li>
<li class="flex items-start">
<span class="flex-shrink-0 bg-blue-500 text-white rounded-full w-6 h-6 flex items-center justify-center mr-3">2</span>
<div>
<h4 class="font-medium text-gray-800">Control Structures</h4>
<p class="text-sm text-gray-600">Master if-else, switch, loops (for, while, do-while)</p>
</div>
</li>
<li class="flex items-start">
<span class="flex-shrink-0 bg-blue-500 text-white rounded-full w-6 h-6 flex items-center justify-center mr-3">3</span>
<div>
<h4 class="font-medium text-gray-800">Methods & Classes</h4>
<p class="text-sm text-gray-600">Understand OOP concepts, constructors, and methods</p>
</div>
</li>
<li class="flex items-start">
<span class="flex-shrink-0 bg-blue-500 text-white rounded-full w-6 h-6 flex items-center justify-center mr-3">4</span>
<div>
<h4 class="font-medium text-gray-800">Arrays & Collections</h4>
<p class="text-sm text-gray-600">Work with arrays, ArrayLists, and basic data structures</p>
</div>
</li>
</ol>
</div>
<!-- Python Path -->
<div class="border-l-4 border-green-500 pl-6">
<h3 class="text-xl font-medium text-gray-800 mb-4 flex items-center">
<img src="https://cdn-icons-png.flaticon.com/512/5968/5968350.png" alt="Python" class="w-6 h-6 mr-2">
Python Fundamentals
</h3>
<ol class="space-y-4">
<li class="flex items-start">
<span class="flex-shrink-0 bg-green-500 text-white rounded-full w-6 h-6 flex items-center justify-center mr-3">1</span>
<div>
<h4 class="font-medium text-gray-800">Variables & Data Types</h4>
<p class="text-sm text-gray-600">Learn dynamic typing, numbers, strings, and lists</p>
</div>
</li>
<li class="flex items-start">
<span class="flex-shrink-0 bg-green-500 text-white rounded-full w-6 h-6 flex items-center justify-center mr-3">2</span>
<div>
<h4 class="font-medium text-gray-800">Control Flow</h4>
<p class="text-sm text-gray-600">Master if-elif-else, loops (for, while), and range()</p>
</div>
</li>
<li class="flex items-start">
<span class="flex-shrink-0 bg-green-500 text-white rounded-full w-6 h-6 flex items-center justify-center mr-3">3</span>
<div>
<h4 class="font-medium text-gray-800">Functions</h4>
<p class="text-sm text-gray-600">Define functions, parameters, return values, and scope</p>
</div>
</li>
<li class="flex items-start">
<span class="flex-shrink-0 bg-green-500 text-white rounded-full w-6 h-6 flex items-center justify-center mr-3">4</span>
<div>
<h4 class="font-medium text-gray-800">Lists & Dictionaries</h4>
<p class="text-sm text-gray-600">Work with sequences, list comprehensions, and dictionaries</p>
</div>
</li>
</ol>
</div>
</div>
</div>
</section>
<!-- Lesson 1: Variables & Data Types -->
<section class="mb-16 bg-white rounded-xl shadow-lg overflow-hidden">
<div class="p-6">
<h2 class="text-2xl font-semibold text-gray-800 mb-6 flex items-center">
<i class="fas fa-cubes mr-3 text-blue-500"></i>
Lesson 1: Variables & Data Types
</h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-8 mb-8">
<div>
<h3 class="text-xl font-medium text-gray-800 mb-3">Java Variables</h3>
<p class="text-gray-600 mb-4">
Java is statically typed, meaning you must declare the variable type before using it.
Primitive types include <code class="bg-gray-100 px-1 rounded">int</code>, <code class="bg-gray-100 px-1 rounded">double</code>,
<code class="bg-gray-100 px-1 rounded">boolean</code>, and <code class="bg-gray-100 px-1 rounded">char</code>.
</p>
<div class="code-editor mb-4">
<pre><code>// Variable declaration and initialization
int age = 25;
double price = 19.99;
boolean isJavaFun = true;
char grade = 'A';
// Constants (cannot be changed)
final double PI = 3.14159;</code></pre>
</div>
</div>
<div>
<h3 class="text-xl font-medium text-gray-800 mb-3">Python Variables</h3>
<p class="text-gray-600 mb-4">
Python is dynamically typed - you don't need to declare variable types.
Common types include <code class="bg-gray-100 px-1 rounded">int</code>, <code class="bg-gray-100 px-1 rounded">float</code>,
<code class="bg-gray-100 px-1 rounded">bool</code>, <code class="bg-gray-100 px-1 rounded">str</code>, and <code class="bg-gray-100 px-1 rounded">list</code>.
</p>
<div class="code-editor mb-4">
<pre><code># Variable assignment
age = 25
price = 19.99
is_python_fun = True
grade = 'A'
# Constants (by convention, not enforced)
PI = 3.14159</code></pre>
</div>
</div>
</div>
<div class="bg-blue-50 p-6 rounded-lg border border-blue-100 mb-8">
<h3 class="text-lg font-medium text-blue-800 mb-3 flex items-center">
<i class="fas fa-lightbulb mr-2 text-blue-600"></i>
Key Differences
</h3>
<ul class="list-disc pl-5 text-gray-700 space-y-2">
<li><strong>Type Declaration:</strong> Java requires explicit type declaration, Python infers types</li>
<li><strong>Constants:</strong> Java has <code class="bg-blue-100 px-1 rounded">final</code> keyword, Python uses naming conventions (UPPER_CASE)</li>
<li><strong>Strings:</strong> Java uses double quotes, Python can use single or double quotes</li>
<li><strong>Boolean Values:</strong> Java uses <code class="bg-blue-100 px-1 rounded">true</code>/<code class="bg-blue-100 px-1 rounded">false</code>, Python uses <code class="bg-blue-100 px-1 rounded">True</code>/<code class="bg-blue-100 px-1 rounded">False</code></li>
</ul>
</div>
<!-- Interactive Exercise -->
<div class="bg-white border border-gray-200 rounded-lg p-6 shadow-sm">
<h3 class="text-xl font-medium text-gray-800 mb-4 flex items-center">
<i class="fas fa-pencil-alt mr-3 text-green-500"></i>
Interactive Exercise
</h3>
<div class="mb-6">
<div class="flex border-b border-gray-200 mb-4">
<button class="tab-button active px-4 py-2 text-blue-600" onclick="changeTab('exercise1', 'java')">
Java
</button>
<button class="tab-button px-4 py-2 text-green-600" onclick="changeTab('exercise1', 'python')">
Python
</button>
</div>
<div id="exercise1-java" class="exercise-content">
<p class="text-gray-600 mb-4">
Fix the variable declarations in this Java code. There are 3 errors to correct.
</p>
<div class="code-editor mb-4">
<pre id="java-code" contenteditable="true">public class Main {
public static void main(String[] args) {
// Fix these variable declarations
int count = "10";
double average = 3.5
boolean isCorrect = "true";
char initial = A;
System.out.println("Count: " + count);
}
}</pre>
</div>
<button onclick="checkExercise('java')" class="bg-blue-600 text-white px-4 py-2 rounded-md hover:bg-blue-700 transition">
Check Solution
</button>
<div id="java-feedback" class="mt-3 hidden"></div>
</div>
<div id="exercise1-python" class="exercise-content hidden">
<p class="text-gray-600 mb-4">
Complete the Python code to calculate the area of a rectangle. Use variables <code class="bg-gray-100 px-1 rounded">length</code> and <code class="bg-gray-100 px-1 rounded">width</code>.
</p>
<div class="code-editor mb-4">
<pre id="python-code" contenteditable="true"># Calculate rectangle area
length = 5
width = 3
# Your code here
print(f"The area is: {area}")</pre>
</div>
<button onclick="checkExercise('python')" class="bg-green-600 text-white px-4 py-2 rounded-md hover:bg-green-700 transition">
Check Solution
</button>
<div id="python-feedback" class="mt-3 hidden"></div>
</div>
</div>
</div>
</div>
</section>
<!-- Lesson 2: Control Structures -->
<section class="mb-16 bg-white rounded-xl shadow-lg overflow-hidden">
<div class="p-6">
<h2 class="text-2xl font-semibold text-gray-800 mb-6 flex items-center">
<i class="fas fa-code-branch mr-3 text-blue-500"></i>
Lesson 2: Control Structures
</h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-8 mb-8">
<div>
<h3 class="text-xl font-medium text-gray-800 mb-3">Java Control Structures</h3>
<p class="text-gray-600 mb-4">
Java uses traditional C-style control structures with curly braces <code class="bg-gray-100 px-1 rounded">{}</code>.
</p>
<div class="code-editor mb-4">
<pre><code>// If-else statement
int score = 85;
if (score >= 90) {
System.out.println("A");
} else if (score >= 80) {
System.out.println("B");
} else {
System.out.println("C");
}
// For loop
for (int i = 0; i < 5; i++) {
System.out.println(i);
}
// While loop
int count = 0;
while (count < 3) {
System.out.println(count);
count++;
}</code></pre>
</div>
</div>
<div>
<h3 class="text-xl font-medium text-gray-800 mb-3">Python Control Structures</h3>
<p class="text-gray-600 mb-4">
Python uses indentation (whitespace) to define code blocks instead of curly braces.
</p>
<div class="code-editor mb-4">
<pre><code># If-elif-else statement
score = 85
if score >= 90:
print("A")
elif score >= 80:
print("B")
else:
print("C")
# For loop (often used with range())
for i in range(5):
print(i)
# While loop
count = 0
while count < 3:
print(count)
count += 1</code></pre>
</div>
</div>
</div>
<!-- Control Structures Exercise -->
<div class="bg-white border border-gray-200 rounded-lg p-6 shadow-sm">
<h3 class="text-xl font-medium text-gray-800 mb-4 flex items-center">
<i class="fas fa-puzzle-piece mr-3 text-purple-500"></i>
Control Structures Challenge
</h3>
<div class="mb-6">
<div class="flex border-b border-gray-200 mb-4">
<button class="tab-button active px-4 py-2 text-blue-600" onclick="changeTab('exercise2', 'java')">
Java
</button>
<button class="tab-button px-4 py-2 text-green-600" onclick="changeTab('exercise2', 'python')">
Python
</button>
</div>
<div id="exercise2-java" class="exercise-content">
<p class="text-gray-600 mb-4">
Write a Java program that prints numbers from 1 to 100. For multiples of 3 print "Fizz",
for multiples of 5 print "Buzz", and for multiples of both print "FizzBuzz".
</p>
<div class="code-editor mb-4">
<pre id="java-control-code" contenteditable="true">public class FizzBuzz {
public static void main(String[] args) {
// Your code here
}
}</pre>
</div>
<button onclick="checkControlExercise('java')" class="bg-blue-600 text-white px-4 py-2 rounded-md hover:bg-blue-700 transition">
Check Solution
</button>
<div id="java-control-feedback" class="mt-3 hidden"></div>
</div>
<div id="exercise2-python" class="exercise-content hidden">
<p class="text-gray-600 mb-4">
Write the same FizzBuzz program in Python. Remember Python uses indentation for blocks!
</p>
<div class="code-editor mb-4">
<pre id="python-control-code" contenteditable="true"># FizzBuzz in Python
# Your code here
</pre>
</div>
<button onclick="checkControlExercise('python')" class="bg-green-600 text-white px-4 py-2 rounded-md hover:bg-green-700 transition">
Check Solution
</button>
<div id="python-control-feedback" class="mt-3 hidden"></div>
</div>
</div>
</div>
</div>
</section>
<!-- Additional Practice -->
<section class="mb-16">
<h2 class="text-2xl font-semibold text-gray-800 mb-6 text-center">Additional Practice Exercises</h2>
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
<div class="exercise-card bg-white p-6 rounded-lg shadow-md border border-gray-100">
<div class="bg-blue-100 w-12 h-12 rounded-full flex items-center justify-center mb-4 text-blue-600">
<i class="fas fa-calculator text-xl"></i>
</div>
<h3 class="font-medium text-gray-800 mb-2">Calculator Program</h3>
<p class="text-sm text-gray-600 mb-4">Create a simple calculator that can add, subtract, multiply, and divide two numbers.</p>
<div class="flex space-x-2">
<span class="bg-blue-100 text-blue-800 text-xs px-2 py-1 rounded">Java</span>
<span class="bg-green-100 text-green-800 text-xs px-2 py-1 rounded">Python</span>
</div>
</div>
<div class="exercise-card bg-white p-6 rounded-lg shadow-md border border-gray-100">
<div class="bg-purple-100 w-12 h-12 rounded-full flex items-center justify-center mb-4 text-purple-600">
<i class="fas fa-sort-amount-down text-xl"></i>
</div>
<h3 class="font-medium text-gray-800 mb-2">Number Guessing Game</h3>
<p class="text-sm text-gray-600 mb-4">Program generates a random number and user tries to guess it with hints.</p>
<div class="flex space-x-2">
<span class="bg-blue-100 text-blue-800 text-xs px-2 py-1 rounded">Java</span>
<span class="bg-green-100 text-green-800 text-xs px-2 py-1 rounded">Python</span>
</div>
</div>
<div class="exercise-card bg-white p-6 rounded-lg shadow-md border border-gray-100">
<div class="bg-amber-100 w-12 h-12 rounded-full flex items-center justify-center mb-4 text-amber-600">
<i class="fas fa-user-friends text-xl"></i>
</div>
<h3 class="font-medium text-gray-800 mb-2">Student Gradebook</h3>
<p class="text-sm text-gray-600 mb-4">Store student names and grades, then calculate averages and find highest/lowest.</p>
<div class="flex space-x-2">
<span class="bg-blue-100 text-blue-800 text-xs px-2 py-1 rounded">Java</span>
<span class="bg-green-100 text-green-800 text-xs px-2 py-1 rounded">Python</span>
</div>
</div>
</div>
</section>
<!-- Resources Section -->
<section class="bg-gray-100 rounded-xl p-8 mb-16">
<h2 class="text-2xl font-semibold text-gray-800 mb-6 text-center">Learning Resources</h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-8">
<div>
<h3 class="text-xl font-medium text-gray-800 mb-4 flex items-center">
<img src="https://cdn-icons-png.flaticon.com/512/226/226777.png" alt="Java" class="w-6 h-6 mr-2">
Java Resources
</h3>
<ul class="space-y-3">
<li>
<a href="https://docs.oracle.com/javase/tutorial/" class="flex items-center text-blue-600 hover:underline">
<i class="fas fa-book mr-2"></i>
Official Java Tutorials
</a>
</li>
<li>
<a href="https://www.codecademy.com/learn/learn-java" class="flex items-center text-blue-600 hover:underline">
<i class="fas fa-laptop-code mr-2"></i>
Codecademy Java Course
</a>
</li>
<li>
<a href="https://codingbat.com/java" class="flex items-center text-blue-600 hover:underline">
<i class="fas fa-edit mr-2"></i>
CodingBat Java Practice
</a>
</li>
</ul>
</div>
<div>
<h3 class="text-xl font-medium text-gray-800 mb-4 flex items-center">
<img src="https://cdn-icons-png.flaticon.com/512/5968/5968350.png" alt="Python" class="w-6 h-6 mr-2">
Python Resources
</h3>
<ul class="space-y-3">
<li>
<a href="https://docs.python.org/3/tutorial/" class="flex items-center text-green-600 hover:underline">
<i class="fas fa-book mr-2"></i>
Official Python Tutorial
</a>
</li>
<li>
<a href="https://www.learnpython.org/" class="flex items-center text-green-600 hover:underline">
<i class="fas fa-laptop-code mr-2"></i>
LearnPython Interactive Tutorial
</a>
</li>
<li>
<a href="https://leetcode.com/problemset/all/" class="flex items-center text-green-600 hover:underline">
<i class="fas fa-edit mr-2"></i>
LeetCode Python Problems
</a>
</li>
</ul>
</div>
</div>
</section>
<footer class="text-center text-gray-600 text-sm mb-8">
<p>Happy coding! Remember that consistent practice is key to mastering programming.</p>
<p class="mt-2">Created with β€οΈ using HTML, CSS, and JavaScript</p>
</footer>
</div>
<script>
// Tab switching functionality
function changeTab(exerciseId, language) {
// Hide all exercise contents for this exercise
document.querySelectorAll(`#${exerciseId}-java, #${exerciseId}-python`).forEach(el => {
el.classList.add('hidden');
});
// Show selected exercise content
document.getElementById(`${exerciseId}-${language}`).classList.remove('hidden');
// Update tab buttons
const buttons = document.querySelectorAll(`#${exerciseId}-java, #${exerciseId}-python`).forEach(el => {
el.parentNode.querySelectorAll('.tab-button').forEach(btn => {
btn.classList.remove('active');
});
});
event.target.classList.add('active');
}
// Exercise checking functionality
function checkExercise(language) {
const feedbackId = `${language}-feedback`;
const feedbackElement = document.getElementById(feedbackId);
if (language === 'java') {
const code = document.getElementById('java-code').textContent;
// Check for common mistakes
if (code.includes('int count = "10"')) {
showFeedback(feedbackElement, "β Error: You can't assign a String to an int variable", false);
} else if (code.includes('double average = 3.5')) {
showFeedback(feedbackElement, "β Error: Missing semicolon after 3.5", false);
} else if (code.includes('boolean isCorrect = "true"')) {
showFeedback(feedbackElement, "β Error: Boolean values don't use quotes", false);
} else if (code.includes('char initial = A')) {
showFeedback(feedbackElement, "β Error: Char values need single quotes", false);
} else {
showFeedback(feedbackElement, "β
Correct! All variable declarations are fixed!", true);
}
} else { // python
const code = document.getElementById('python-code').textContent;
if (code.includes('area = length * width')) {
showFeedback(feedbackElement, "β
Correct! The area is calculated properly.", true);
} else {
showFeedback(feedbackElement, "β Try calculating the area by multiplying length and width", false);
}
}
}
function checkControlExercise(language) {
const feedbackId = `${language}-control-feedback`;
const feedbackElement = document.getElementById(feedbackId);
if (language === 'java') {
const code = document.getElementById('java-control-code').textContent;
if (code.includes("if (i % 15 == 0)") ||
(code.includes("i % 3 == 0") && code.includes("i % 5 == 0"))) {
showFeedback(feedbackElement, "β
Excellent FizzBuzz implementation!", true);
} else if (code.includes("System.out.println") && code.includes("for")) {
showFeedback(feedbackElement, "β οΈ Close! Did you handle the FizzBuzz case (divisible by 3 and 5)?", false);
} else {
showFeedback(feedbackElement, "β Try using a for loop and if-else conditions", false);
}
} else { // python
const code = document.getElementById('python-control-code').textContent;
if (code.includes("if i % 15 == 0") ||
(code.includes("i % 3 == 0") && code.includes("i % 5 == 0"))) {
showFeedback(feedbackElement, "β
Perfect Python FizzBuzz solution!", true);
} else if (code.includes("print") && code.includes("for i in range")) {
showFeedback(feedbackElement, "β οΈ Almost there! Check your conditions for FizzBuzz", false);
} else {
showFeedback(feedbackElement, "β Remember Python uses indentation and elif", false);
}
}
}
function showFeedback(element, message, isSuccess) {
element.classList.remove('hidden');
element.textContent = message;
element.className = isSuccess ? 'mt-3 text-green-600' : 'mt-3 text-red-600';
}
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 𧬠<a href="https://enzostvs-deepsite.hf.space?remix=Puretarantino/learning-tools" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html> |