File size: 40,216 Bytes
7c1cbb9
 
 
 
 
 
 
 
44f5b68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7c1cbb9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44f5b68
 
 
 
 
 
 
 
 
 
 
7c1cbb9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44f5b68
 
7c1cbb9
 
 
 
 
 
 
 
 
 
44f5b68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7c1cbb9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44f5b68
7c1cbb9
44f5b68
 
 
 
 
 
 
 
 
7c1cbb9
 
 
 
44f5b68
7c1cbb9
44f5b68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7c1cbb9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44f5b68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7c1cbb9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44f5b68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7c1cbb9
 
 
 
 
 
 
44f5b68
 
 
 
 
 
 
 
 
7c1cbb9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Python Quiz Generator</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">
    <!-- Shop Modal -->
    <div id="shopModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
        <div class="bg-gray-800 rounded-xl shadow-2xl p-8 max-w-2xl w-full max-h-[90vh] overflow-y-auto">
            <div class="flex justify-between items-center mb-6">
                <h2 class="text-3xl font-bold">Power-Up Shop</h2>
                <button id="closeShop" class="text-gray-400 hover:text-white text-2xl">&times;</button>
            </div>
            
            <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                <!-- Power-Up Items -->
                <div class="bg-gray-700 rounded-lg p-4 border-2 border-python-blue">
                    <div class="flex justify-between items-start mb-3">
                        <h3 class="text-xl font-bold">50/50</h3>
                        <div class="flex items-center">
                            <i class="fas fa-coins text-python-yellow mr-1"></i>
                            <span>100</span>
                        </div>
                    </div>
                    <p class="text-gray-300 mb-4">Eliminates two wrong answers</p>
                    <button class="buy-btn w-full bg-python-blue hover:bg-python-light text-white font-bold py-2 px-4 rounded-lg transition-all" data-powerup="5050" data-cost="100">
                        Buy
                    </button>
                </div>

                <div class="bg-gray-700 rounded-lg p-4 border-2 border-python-yellow">
                    <div class="flex justify-between items-start mb-3">
                        <h3 class="text-xl font-bold">Time Freeze</h3>
                        <div class="flex items-center">
                            <i class="fas fa-coins text-python-yellow mr-1"></i>
                            <span>150</span>
                        </div>
                    </div>
                    <p class="text-gray-300 mb-4">Gives you extra 30 seconds per question</p>
                    <button class="buy-btn w-full bg-python-yellow hover:bg-yellow-400 text-gray-800 font-bold py-2 px-4 rounded-lg transition-all" data-powerup="timefreeze" data-cost="150">
                        Buy
                    </button>
                </div>

                <div class="bg-gray-700 rounded-lg p-4 border-2 border-python-light">
                    <div class="flex justify-between items-start mb-3">
                        <h3 class="text-xl font-bold">Double Points</h3>
                        <div class="flex items-center">
                            <i class="fas fa-coins text-python-yellow mr-1"></i>
                            <span>200</span>
                        </div>
                    </div>
                    <p class="text-gray-300 mb-4">Next correct answer gives double points</p>
                    <button class="buy-btn w-full bg-python-light hover:bg-blue-400 text-white font-bold py-2 px-4 rounded-lg transition-all" data-powerup="doublepoints" data-cost="200">
                        Buy
                    </button>
                </div>

                <div class="bg-gray-700 rounded-lg p-4 border-2 border-green-500">
                    <div class="flex justify-between items-start mb-3">
                        <h3 class="text-xl font-bold">Skip Question</h3>
                        <div class="flex items-center">
                            <i class="fas fa-coins text-python-yellow mr-1"></i>
                            <span>75</span>
                        </div>
                    </div>
                    <p class="text-gray-300 mb-4">Skip the current question</p>
                    <button class="buy-btn w-full bg-green-500 hover:bg-green-400 text-white font-bold py-2 px-4 rounded-lg transition-all" data-powerup="skip" data-cost="75">
                        Buy
                    </button>
                </div>
            </div>
        </div>
    </div>

    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        'python-blue': '#306998',
                        'python-yellow': '#FFD43B',
                        'python-light': '#4B8BBE',
                    },
                    animation: {
                        'pulse-slow': 'pulse 3s cubic-bezier(0.4, 0, 0.6, 1) infinite',
                        'bounce-slow': 'bounce 2s infinite',
                    }
                }
            }
        }
    </script>
    <style>
        @import url('https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@400;500;600;700&display=swap');
        
        body {
            font-family: 'Source Code Pro', monospace;
            background: linear-gradient(135deg, #1a2a6c, #2c3e50);
            min-height: 100vh;
        }
        
        .python-logo {
            animation: spin 20s linear infinite;
        }
        
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
        
        .option-card {
            transition: all 0.3s ease;
            transform: scale(1);
        }
        
        .option-card:hover {
            transform: scale(1.03);
            box-shadow: 0 10px 25px rgba(0,0,0,0.2);
        }
        
        .correct-answer {
            animation: correct-pulse 0.5s ease;
            box-shadow: 0 0 0 4px rgba(72, 187, 120, 0.5);
        }
        
        .incorrect-answer {
            animation: shake 0.5s ease;
            box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.5);
        }
        
        @keyframes correct-pulse {
            0% { transform: scale(1); }
            50% { transform: scale(1.05); }
            100% { transform: scale(1); }
        }
        
        @keyframes shake {
            0%, 100% { transform: translateX(0); }
            25% { transform: translateX(-5px); }
            75% { transform: translateX(5px); }
        }
        
        .progress-bar {
            transition: width 0.5s ease;
        }
        
        .snake-animation {
            animation: snake-move 8s linear infinite;
        }
        
        @keyframes snake-move {
            0% { transform: translateX(-100%); }
            100% { transform: translateX(100%); }
        }
        
        .code-block {
            font-family: 'Source Code Pro', monospace;
            background: #2d3748;
            border-left: 4px solid #4B8BBE;
        }
    </style>
</head>
<body class="text-gray-100">
    <!-- Main Container -->
    <div class="container mx-auto px-4 py-8 max-w-4xl">
        <!-- Header -->
        <header class="text-center mb-12">
            <div class="flex justify-center mb-4">
                <div class="python-logo bg-python-blue rounded-full w-24 h-24 flex items-center justify-center">
                    <div class="bg-python-yellow rounded-full w-16 h-16 flex items-center justify-center">
                        <i class="fas fa-code text-python-blue text-3xl"></i>
                    </div>
                </div>
            </div>
            <h1 class="text-4xl md:text-5xl font-bold mb-2 bg-gradient-to-r from-python-yellow to-python-light bg-clip-text text-transparent">
                Python Quiz Generator
            </h1>
            <p class="text-xl text-gray-300">Test your Python knowledge with interactive challenges!</p>
        </header>

        <!-- Currency Display -->
        <div class="bg-gray-800 rounded-xl shadow-2xl p-4 mb-4 flex justify-between items-center">
            <div class="flex items-center">
                <i class="fas fa-coins text-python-yellow text-2xl mr-2"></i>
                <span id="coinCount" class="text-xl font-bold">0</span>
            </div>
            <button id="shopBtn" class="bg-python-light hover:bg-python-blue text-white font-bold py-2 px-4 rounded-lg transition-all">
                <i class="fas fa-store mr-2"></i> Shop
            </button>
        </div>

        <!-- Quiz Controls -->
        <div class="bg-gray-800 rounded-xl shadow-2xl p-6 mb-8">
            <div class="flex flex-wrap justify-between items-center gap-4">
                <div>
                    <h2 class="text-2xl font-bold mb-2">Quiz Settings</h2>
                    <p class="text-gray-400">Customize your quiz experience</p>
                </div>
                
                <div class="flex flex-wrap gap-3">
                    <div class="flex items-center">
                        <label class="mr-2">Questions:</label>
                        <select id="questionCount" class="bg-gray-700 text-white rounded px-3 py-1">
                            <option>5</option>
                            <option selected>10</option>
                            <option>15</option>
                            <option>20</option>
                        </select>
                    </div>
                    
                    <div class="flex items-center">
                        <label class="mr-2">Difficulty:</label>
                        <select id="difficulty" class="bg-gray-700 text-white rounded px-3 py-1">
                            <option>Beginner</option>
                            <option selected>Intermediate</option>
                            <option>Advanced</option>
                        </select>
                    </div>
                    
                    <button id="generateBtn" class="bg-python-blue hover:bg-python-light text-white font-bold py-2 px-6 rounded-lg transition-all transform hover:scale-105 flex items-center">
                        <i class="fas fa-bolt mr-2"></i> Generate Quiz
                    </button>
                </div>
            </div>
        </div>

        <!-- Quiz Container -->
        <div id="quizContainer" class="hidden">
            <!-- Progress Bar -->
            <div class="mb-6">
                <div class="flex justify-between mb-2">
                    <div class="text-lg font-bold">
                        Question <span id="currentQuestion">1</span> of <span id="totalQuestions">10</span>
                    </div>
                    <div class="text-lg font-bold">
                        Score: <span id="score">0</span>
                    </div>
                </div>
                <div class="h-3 bg-gray-700 rounded-full overflow-hidden">
                    <div id="progressBar" class="h-full bg-python-blue rounded-full progress-bar" style="width: 10%"></div>
                </div>
            </div>

            <!-- Question Area -->
            <div class="bg-gray-800 rounded-xl shadow-2xl p-6 mb-6">
                <div class="flex items-start mb-6">
                    <div class="bg-python-blue text-python-yellow rounded-full w-10 h-10 flex items-center justify-center mr-4 flex-shrink-0">
                        <i class="fas fa-question"></i>
                    </div>
                    <div>
                        <h3 id="questionText" class="text-xl font-bold mb-2">What is the output of the following Python code?</h3>
                        <div class="code-block p-4 rounded-lg mt-3">
                            <pre id="questionCode" class="text-green-400">print(2 + 2 * 3)</pre>
                        </div>
                    </div>
                </div>
                
                <!-- Options -->
                <div class="grid grid-cols-1 md:grid-cols-2 gap-4 mt-6">
                    <div class="option-card bg-gray-700 rounded-lg p-4 cursor-pointer">
                        <div class="flex items-center">
                            <div class="bg-gray-600 rounded-full w-8 h-8 flex items-center justify-center mr-3">A</div>
                            <span class="option-text">8</span>
                        </div>
                    </div>
                    <div class="option-card bg-gray-700 rounded-lg p-4 cursor-pointer">
                        <div class="flex items-center">
                            <div class="bg-gray-600 rounded-full w-8 h-8 flex items-center justify-center mr-3">B</div>
                            <span class="option-text">10</span>
                        </div>
                    </div>
                    <div class="option-card bg-gray-700 rounded-lg p-4 cursor-pointer">
                        <div class="flex items-center">
                            <div class="bg-gray-600 rounded-full w-8 h-8 flex items-center justify-center mr-3">C</div>
                            <span class="option-text">12</span>
                        </div>
                    </div>
                    <div class="option-card bg-gray-700 rounded-lg p-4 cursor-pointer">
                        <div class="flex items-center">
                            <div class="bg-gray-600 rounded-full w-8 h-8 flex items-center justify-center mr-3">D</div>
                            <span class="option-text">6</span>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Explanation -->
            <div id="explanation" class="hidden bg-gray-800 rounded-xl shadow-2xl p-6 mb-6">
                <div class="flex items-start">
                    <div class="bg-green-500 text-white rounded-full w-10 h-10 flex items-center justify-center mr-4 flex-shrink-0">
                        <i class="fas fa-lightbulb"></i>
                    </div>
                    <div>
                        <h3 class="text-xl font-bold mb-2">Explanation</h3>
                        <p id="explanationText" class="text-gray-300">In Python, multiplication has higher precedence than addition. So 2 * 3 is calculated first (resulting in 6), then 2 + 6 is calculated, giving 8.</p>
                    </div>
                </div>
            </div>

            <!-- Navigation -->
            <div class="flex justify-between">
                <button id="prevBtn" class="bg-gray-700 hover:bg-gray-600 text-white font-bold py-2 px-6 rounded-lg transition-all">
                    <i class="fas fa-arrow-left mr-2"></i> Previous
                </button>
                <button id="nextBtn" class="bg-python-blue hover:bg-python-light text-white font-bold py-2 px-6 rounded-lg transition-all transform hover:scale-105">
                    Next <i class="fas fa-arrow-right ml-2"></i>
                </button>
            </div>
        </div>

        <!-- Snake Animation Decoration -->
        <div class="relative h-4 my-12 overflow-hidden">
            <div class="snake-animation absolute top-0 left-0 w-full">
                <div class="flex">
                    <div class="w-4 h-4 bg-python-blue rounded-full mx-1"></div>
                    <div class="w-4 h-4 bg-python-yellow rounded-full mx-1"></div>
                    <div class="w-4 h-4 bg-python-light rounded-full mx-1"></div>
                    <div class="w-4 h-4 bg-python-blue rounded-full mx-1"></div>
                    <div class="w-4 h-4 bg-python-yellow rounded-full mx-1"></div>
                    <div class="w-4 h-4 bg-python-light rounded-full mx-1"></div>
                </div>
            </div>
        </div>

        <!-- Results Container -->
        <div id="resultsContainer" class="hidden bg-gray-800 rounded-xl shadow-2xl p-8">
            <div class="text-center mb-8">
            <div class="flex justify-center mb-6">
                <div class="bg-gradient-to-br from-python-blue to-python-light rounded-full w-24 h-24 flex items-center justify-center">
                    <i class="fas fa-trophy text-white text-4xl"></i>
                </div>
            </div>
            <h2 class="text-3xl font-bold mb-4">Quiz Completed!</h2>
            <div class="text-5xl font-bold mb-6 bg-gradient-to-r from-python-yellow to-python-light bg-clip-text text-transparent">
                <span id="finalScore">8</span>/<span id="finalTotal">10</span>
            </div>
            <p id="resultMessage" class="text-xl mb-8">Great job! You have a solid understanding of Python fundamentals.</p>
            <!-- Analytics Section -->
            <div class="bg-gray-700 rounded-xl p-6 mb-8">
                <h3 class="text-2xl font-bold mb-4 text-center">Your Performance Analysis</h3>
                
                <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                    <!-- Weak Areas -->
                    <div class="bg-gray-800 rounded-lg p-4">
                        <h4 class="text-xl font-bold mb-3 flex items-center">
                            <i class="fas fa-exclamation-triangle text-red-400 mr-2"></i> Weak Areas
                        </h4>
                        <ul id="weakAreas" class="space-y-2">
                            <!-- Dynamically populated -->
                        </ul>
                    </div>
                    
                    <!-- Progress Chart -->
                    <div class="bg-gray-800 rounded-lg p-4">
                        <h4 class="text-xl font-bold mb-3 flex items-center">
                            <i class="fas fa-chart-line text-green-400 mr-2"></i> Progress
                        </h4>
                        <div class="h-48" id="progressChart">
                            <!-- Chart will be rendered here -->
                        </div>
                    </div>
                    
                    <!-- Mnemonics -->
                    <div class="bg-gray-800 rounded-lg p-4">
                        <h4 class="text-xl font-bold mb-3 flex items-center">
                            <i class="fas fa-brain text-purple-400 mr-2"></i> Memory Aids
                        </h4>
                        <div id="mnemonics" class="space-y-3">
                            <!-- Dynamically populated -->
                        </div>
                    </div>
                    
                    <!-- Flashcards -->
                    <div class="bg-gray-800 rounded-lg p-4">
                        <h4 class="text-xl font-bold mb-3 flex items-center">
                            <i class="fas fa-layer-group text-blue-400 mr-2"></i> Key Concepts
                        </h4>
                        <div id="flashcards" class="grid grid-cols-2 gap-3">
                            <!-- Dynamically populated -->
                        </div>
                    </div>
                </div>
            </div>

            <div class="flex justify-center gap-4">
                <button id="restartBtn" class="bg-python-blue hover:bg-python-light text-white font-bold py-3 px-8 rounded-lg transition-all transform hover:scale-105">
                    <i class="fas fa-redo mr-2"></i> Try Again
                </button>
                <button id="newQuizBtn" class="bg-gray-700 hover:bg-gray-600 text-white font-bold py-3 px-8 rounded-lg transition-all">
                    <i class="fas fa-plus mr-2"></i> New Quiz
                </button>
            </div>
        </div>
    </div>

    <script>
        // Quiz questions database
        const questions = [
            {
                question: "What is the output of the following Python code?",
                code: "print(2 + 2 * 3)",
                options: ["8", "10", "12", "6"],
                answer: 0,
                explanation: "In Python, multiplication has higher precedence than addition. So 2 * 3 is calculated first (resulting in 6), then 2 + 6 is calculated, giving 8."
            },
            {
                question: "Which of the following is used to create a virtual environment in Python?",
                code: "",
                options: ["venv", "virtualenv", "pipenv", "All of the above"],
                answer: 3,
                explanation: "All of these tools can be used to create virtual environments in Python. venv is built into Python 3, virtualenv is a third-party tool, and pipenv combines virtual environment management with package management."
            },
            {
                question: "What does the 'yield' keyword do in Python?",
                code: "",
                options: [
                    "Returns a value and terminates the function",
                    "Pauses the function and returns a generator object",
                    "Used for exception handling",
                    "Defines a static method"
                ],
                answer: 1,
                explanation: "The yield keyword is used in generator functions to pause execution and return a value. When called again, the function resumes where it left off."
            },
            {
                question: "What is the output of the following code?",
                code: "x = [1, 2, 3]\ny = x\ny.append(4)\nprint(x)",
                options: ["[1, 2, 3]", "[1, 2, 3, 4]", "[4]", "Error"],
                answer: 1,
                explanation: "When we assign y = x, both variables point to the same list in memory. So modifying y also modifies x."
            },
            {
                question: "Which method would you use to remove the last element from a list?",
                code: "",
                options: ["list.remove()", "list.pop()", "list.delete()", "list.cut()"],
                answer: 1,
                explanation: "The pop() method removes and returns the last element by default. You can also specify an index to remove an element at a specific position."
            },
            {
                question: "What is the purpose of __init__ in a Python class?",
                code: "",
                options: [
                    "To initialize the class object",
                    "To create class methods",
                    "To define class variables",
                    "To terminate the class instance"
                ],
                answer: 0,
                explanation: "The __init__ method is called when a new instance of a class is created. It's used to initialize the object's attributes."
            },
            {
                question: "What does the 'with' statement do?",
                code: "",
                options: [
                    "Creates a loop",
                    "Handles exceptions",
                    "Manages resources and ensures cleanup",
                    "Defines a context for variable scope"
                ],
                answer: 2,
                explanation: "The 'with' statement simplifies resource management by ensuring that setup and cleanup operations are performed automatically."
            },
            {
                question: "What is the output of the following code?",
                code: "print([i for i in range(10) if i % 2 == 0])",
                options: [
                    "[0, 2, 4, 6, 8]",
                    "[2, 4, 6, 8]",
                    "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]",
                    "[1, 3, 5, 7, 9]"
                ],
                answer: 0,
                explanation: "This list comprehension generates numbers from 0 to 9, but only includes even numbers (where i % 2 == 0)."
            },
            {
                question: "Which of these is NOT a valid variable name?",
                code: "",
                options: ["_private", "2nd_variable", "variable_name", "camelCase"],
                answer: 1,
                explanation: "Variable names cannot start with a number. They must start with a letter or underscore."
            },
            {
                question: "What is the purpose of the 'pass' statement?",
                code: "",
                options: [
                    "To terminate the program",
                    "To skip the current iteration in a loop",
                    "As a placeholder where syntax requires a statement",
                    "To pass arguments to a function"
                ],
                answer: 2,
                explanation: "The pass statement is a null operation - it does nothing. It's used when a statement is required syntactically but no action is needed."
            }
        ];

        // DOM Elements
        const quizContainer = document.getElementById('quizContainer');
        const resultsContainer = document.getElementById('resultsContainer');
        const generateBtn = document.getElementById('generateBtn');
        const questionText = document.getElementById('questionText');
        const questionCode = document.getElementById('questionCode');
        const optionElements = document.querySelectorAll('.option-card');
        const optionTexts = document.querySelectorAll('.option-text');
        const explanation = document.getElementById('explanation');
        const explanationText = document.getElementById('explanationText');
        const currentQuestionEl = document.getElementById('currentQuestion');
        const totalQuestionsEl = document.getElementById('totalQuestions');
        const scoreEl = document.getElementById('score');
        const progressBar = document.getElementById('progressBar');
        const prevBtn = document.getElementById('prevBtn');
        const nextBtn = document.getElementById('nextBtn');
        const finalScore = document.getElementById('finalScore');
        const finalTotal = document.getElementById('finalTotal');
        const resultMessage = document.getElementById('resultMessage');
        const restartBtn = document.getElementById('restartBtn');
        const newQuizBtn = document.getElementById('newQuizBtn');

        // Enhanced quiz state
        let currentQuestionIndex = 0;
        let coins = 0;
        let powerups = {
            '5050': 0,
            'timefreeze': 0,
            'doublepoints': 0,
            'skip': 0
        };
        let weakAreas = {};
        let questionHistory = [];
        let score = 0;
        let userAnswers = [];
        let quizQuestions = [];

        // Initialize with new features
        document.addEventListener('DOMContentLoaded', () => {
            // Load saved coins from localStorage
            coins = parseInt(localStorage.getItem('pythonQuizCoins')) || 0;
            updateCoinDisplay();
            
            // Shop functionality
            const shopBtn = document.getElementById('shopBtn');
            const shopModal = document.getElementById('shopModal');
            const closeShop = document.getElementById('closeShop');
            
            shopBtn.addEventListener('click', () => shopModal.classList.remove('hidden'));
            closeShop.addEventListener('click', () => shopModal.classList.add('hidden'));
            
            // Handle powerup purchases
            document.querySelectorAll('.buy-btn').forEach(btn => {
                btn.addEventListener('click', function() {
                    const powerup = this.dataset.powerup;
                    const cost = parseInt(this.dataset.cost);
                    
                    if (coins >= cost) {
                        coins -= cost;
                        powerups[powerup]++;
                        updateCoinDisplay();
                        localStorage.setItem('pythonQuizCoins', coins);
                        alert(`Purchased ${powerup}! You now have ${powerups[powerup]}`);
                    } else {
                        alert("Not enough coins!");
                    }
                });
            });
            generateBtn.addEventListener('click', startQuiz);
            optionElements.forEach((option, index) => {
                option.addEventListener('click', () => selectAnswer(index));
            });
            nextBtn.addEventListener('click', nextQuestion);
            prevBtn.addEventListener('click', prevQuestion);
            restartBtn.addEventListener('click', restartQuiz);
            newQuizBtn.addEventListener('click', () => {
                resultsContainer.classList.add('hidden');
                document.querySelector('.container').classList.remove('hidden');
            });
        });

        // Start quiz
        function startQuiz() {
            const questionCount = parseInt(document.getElementById('questionCount').value);
            const difficulty = document.getElementById('difficulty').value;
            
            // Select random questions based on count
            quizQuestions = [...questions].sort(() => 0.5 - Math.random()).slice(0, questionCount);
            
            // Reset state
            currentQuestionIndex = 0;
            score = 0;
            userAnswers = [];
            
            // Update UI
            quizContainer.classList.remove('hidden');
            document.querySelector('.container > div:nth-child(2)').classList.add('hidden'); // Hide settings
            totalQuestionsEl.textContent = quizQuestions.length;
            scoreEl.textContent = score;
            updateQuestion();
        }

        // Update question display
        function updateQuestion() {
            const question = quizQuestions[currentQuestionIndex];
            
            questionText.textContent = question.question;
            questionCode.textContent = question.code || "";
            questionCode.parentElement.style.display = question.code ? "block" : "none";
            
            optionTexts.forEach((option, index) => {
                option.textContent = question.options[index];
            });
            
            currentQuestionEl.textContent = currentQuestionIndex + 1;
            scoreEl.textContent = score;
            progressBar.style.width = `${((currentQuestionIndex + 1) / quizQuestions.length) * 100}%`;
            
            // Reset option styles
            optionElements.forEach(option => {
                option.classList.remove('correct-answer', 'incorrect-answer');
                option.style.pointerEvents = 'auto';
            });
            
            explanation.classList.add('hidden');
            prevBtn.disabled = currentQuestionIndex === 0;
            
            // Hide next button until answer is selected
            nextBtn.classList.add('hidden');
        }

        // Update coin display
        function updateCoinDisplay() {
            document.getElementById('coinCount').textContent = coins;
        }

        // Award coins for correct answers
        function awardCoins(isCorrect, difficulty) {
            let amount = 0;
            if (isCorrect) {
                amount = difficulty === 'Beginner' ? 10 : 
                         difficulty === 'Intermediate' ? 20 : 30;
                coins += amount;
                updateCoinDisplay();
                localStorage.setItem('pythonQuizCoins', coins);
                
                // Show coin animation
                const coinAnim = document.createElement('div');
                coinAnim.className = 'absolute -top-2 -right-2 bg-python-yellow text-gray-800 font-bold rounded-full w-8 h-8 flex items-center justify-center animate-bounce';
                coinAnim.innerHTML = `+${amount}`;
                document.getElementById('coinCount').parentNode.appendChild(coinAnim);
                
                setTimeout(() => coinAnim.remove(), 2000);
            }
        }

        // Handle answer selection with powerups
        function selectAnswer(selectedIndex) {
            const question = quizQuestions[currentQuestionIndex];
            const correctIndex = question.answer;
            
            // Only allow one selection
            if (userAnswers[currentQuestionIndex] !== undefined) return;
            
            // Disable further selections
            optionElements.forEach(option => {
                option.style.pointerEvents = 'none';
            });
            
            // Mark correct answer
            optionElements[correctIndex].classList.add('correct-answer');
            
            // Store user answer
            userAnswers[currentQuestionIndex] = selectedIndex;
            
            // Check if answer is correct
            if (selectedIndex === correctIndex) {
                score++;
                scoreEl.textContent = score;
            } else {
                // Mark incorrect answer
                optionElements[selectedIndex].classList.add('incorrect-answer');
            }
            
            // Show explanation
            explanationText.textContent = question.explanation;
            explanation.classList.remove('hidden');
            
            // Show next button if not last question
            if (currentQuestionIndex < quizQuestions.length - 1) {
                nextBtn.classList.remove('hidden');
            } else {
                nextBtn.textContent = "Finish Quiz";
                nextBtn.classList.remove('hidden');
            }
        }

        // Navigate to next question
        function nextQuestion() {
            if (currentQuestionIndex < quizQuestions.length - 1) {
                currentQuestionIndex++;
                updateQuestion();
            } else {
                // Only show results if all questions answered
                if (userAnswers.length === quizQuestions.length) {
                    showResults();
                }
            }
        }

        // Navigate to previous question
        function prevQuestion() {
            if (currentQuestionIndex > 0) {
                currentQuestionIndex--;
                updateQuestion();
                
                // Reapply answer state if already answered
                if (userAnswers[currentQuestionIndex] !== undefined) {
                    const question = quizQuestions[currentQuestionIndex];
                    const correctIndex = question.answer;
                    const userAnswer = userAnswers[currentQuestionIndex];
                    
                    optionElements.forEach(option => {
                        option.style.pointerEvents = 'none';
                    });
                    
                    optionElements[correctIndex].classList.add('correct-answer');
                    
                    if (userAnswer !== correctIndex) {
                        optionElements[userAnswer].classList.add('incorrect-answer');
                    }
                    
                    explanationText.textContent = question.explanation;
                    explanation.classList.remove('hidden');
                    nextBtn.classList.remove('hidden');
                }
            }
        }

        // Analyze weak areas
        function analyzeWeakAreas() {
            weakAreas = {};
            quizQuestions.forEach((q, i) => {
                if (userAnswers[i] !== q.answer) {
                    const category = q.question.split(' ')[0]; // Simple categorization
                    weakAreas[category] = (weakAreas[category] || 0) + 1;
                }
            });
            
            // Sort weak areas
            const sortedWeakAreas = Object.entries(weakAreas)
                .sort((a, b) => b[1] - a[1])
                .slice(0, 3);
            
            // Display weak areas
            const weakAreasList = document.getElementById('weakAreas');
            weakAreasList.innerHTML = sortedWeakAreas.map(([area, count]) => `
                <li class="flex justify-between items-center">
                    <span>${area}</span>
                    <span class="bg-red-500 text-white text-sm px-2 py-1 rounded-full">${count} mistakes</span>
                </li>
            `).join('');
            
            // Generate mnemonics for weak areas
            const mnemonicsContainer = document.getElementById('mnemonics');
            mnemonicsContainer.innerHTML = sortedWeakAreas.map(([area]) => {
                const mnemonic = generateMnemonic(area);
                return `
                    <div class="bg-gray-900 p-3 rounded-lg">
                        <div class="font-bold text-python-yellow mb-1">${area}</div>
                        <div>${mnemonic}</div>
                    </div>
                `;
            }).join('');
            
            // Generate flashcards
            const flashcardsContainer = document.getElementById('flashcards');
            flashcardsContainer.innerHTML = quizQuestions
                .filter((q, i) => userAnswers[i] !== q.answer)
                .slice(0, 4)
                .map(q => `
                    <div class="flashcard bg-gray-900 p-3 rounded-lg cursor-pointer transform transition hover:scale-105" onclick="this.classList.toggle('bg-gray-800')">
                        <div class="font-bold text-python-blue">Q: ${q.question.substring(0, 50)}...</div>
                        <div class="hidden mt-2 text-sm">A: ${q.options[q.answer]}</div>
                    </div>
                `).join('');
        }

        // Simple mnemonic generator
        function generateMnemonic(topic) {
            const mnemonics = {
                "What": "When in doubt, PEMDAS rules them all (Parentheses, Exponents, Multiplication/Division, Addition/Subtraction)",
                "Which": "VENV is Very Essential for New Versions",
                "What does": "Yield gives you a generator - it 'yields' results one by one",
                "Which method": "POP goes the last element! (like popcorn popping out)"
            };
            return mnemonics[topic] || "Practice makes perfect! Review this concept regularly.";
        }

        // Show enhanced results
        function showResults() {
            quizContainer.classList.add('hidden');
            resultsContainer.classList.remove('hidden');
            
            finalScore.textContent = score;
            finalTotal.textContent = quizQuestions.length;
            
            // Award bonus coins based on performance
            const bonus = Math.floor(score * 5);
            coins += bonus;
            updateCoinDisplay();
            localStorage.setItem('pythonQuizCoins', coins);
            
            // Analyze performance
            analyzeWeakAreas();
            
            // Custom message based on score
            const percentage = (score / quizQuestions.length) * 100;
            if (percentage >= 90) {
                resultMessage.textContent = "Python Master! Your skills are exceptional.";
            } else if (percentage >= 70) {
                resultMessage.textContent = "Great job! You have a strong understanding of Python.";
            } else if (percentage >= 50) {
                resultMessage.textContent = "Good effort! Keep practicing to improve your skills.";
            } else {
                resultMessage.textContent = "Keep learning! Review the basics and try again.";
            }
        }

        // Restart quiz
        function restartQuiz() {
            resultsContainer.classList.add('hidden');
            quizContainer.classList.remove('hidden');
            document.querySelector('.container > div:nth-child(2)').classList.remove('hidden');
            
            // Reset to first question
            currentQuestionIndex = 0;
            score = 0;
            userAnswers = [];
            
            updateQuestion();
            nextBtn.textContent = "Next";
        }
    </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=casv/pythonquizgenerator" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>