diff --git a/summership-26-prs/Pradeep Mishra/README.md b/summership-26-prs/Pradeep Mishra/README.md new file mode 100644 index 0000000..329c883 --- /dev/null +++ b/summership-26-prs/Pradeep Mishra/README.md @@ -0,0 +1,146 @@ +# PyBe Discovery Lab — The Gates of Rajgad + +> An interactive, story-driven learning module that teaches **Python Decorators** through the security protocol of Rajgad Fort (1665 CE). + +--- + +# Overview + +Most Python tutorials explain decorators using abstract examples. This project introduces the concept through a historical story inspired by **Rajgad Fort**, helping learners understand the decorator pattern before seeing any Python code. + +The story follows **Subedar Yesaji Kank**, who follows a strict three-phase security protocol for every royal messenger entering Rajgad Fort. This sequence directly mirrors how a Python decorator works. + +--- + +# Learning Objective + +This project teaches the Python Decorator execution flow: + +``` +BEFORE → MAIN FUNCTION → AFTER +``` + +Example: + +```python +def security(func): + def wrapper(): + print("Before") # Kank checks the Mudra token + result = func() # Messenger delivers the scroll + print("After") # Kank logs the exit in Rojkird + return result + return wrapper + +@security +def deliver_message(): + print("Delivering message") + return "Done" + +deliver_message() +``` + +--- + +# Story + +It is **1665 CE**. + +A royal messenger arrives at **Maha Darwaja**, the main entrance of Rajgad Fort, carrying a sealed scroll for **Chhatrapati Shivaji Maharaj**. + +Before allowing entry, **Subedar Yesaji Kank** verifies the Mudra token and the royal seal. + +After successful verification: + +1. The messenger enters the fort. +2. The message is delivered. +3. The exit is recorded in the **Rojkird** (official fort ledger). + +Every mission follows the same protocol. + +Learners experience this journey through an interactive story before discovering its connection to Python decorators. + +--- + +# Screens + +| Screen | Description | +|---------|-------------| +| Welcome | Introduction to Rajgad Fort | +| Maha Darwaja | Problem statement | +| Inspection by Kank | BEFORE phase | +| Audience with Maharaj | MAIN FUNCTION | +| Rojkird Log | AFTER phase | +| Python Connection | Story mapped to Python code | +| Quiz 1 | Identify the decorator | +| Quiz 2 | Identify the main function | +| Quiz 3 | Identify the AFTER phase | +| Completion | Summary and congratulations | + +--- + +# Features + +- Story-first learning approach +- Interactive quiz with guided feedback +- Story-to-code mapping +- Re-runnable Python terminal animation +- Syntax-highlighted code editor +- BEFORE / MAIN / AFTER phase visualization +- Smooth animations and transitions +- Canvas-based particle effects +- Previous/Next navigation +- Beginner-friendly explanation of Python decorators + +--- + +# Technologies Used + +- HTML5 +- CSS3 +- JavaScript (Vanilla) +- Canvas API +- Google Fonts +- CSS Animations + +--- + +# Project Structure + +``` +pybe-discovery-lab/ +│ +├── index.html +└── assets/ + ├── rajgad_welcome.jpg + ├── step1_arrival.jpg + ├── step2_verification.jpg + ├── step3_durbar.jpg + └── step4_ledger.jpg +``` + +--- + +# Design Decisions + +- **Single-file architecture** for simplicity and easy sharing. +- **No frameworks** to keep the project lightweight. +- **Story-first learning** to help beginners understand decorators intuitively. +- **Historical theme** to make learning engaging and memorable. + +--- + +# Context + +Developed as part of the **PyBe (Python Beginner Experience)** course project. + +The target audience is beginners learning **Python Decorators** for the first time. + +--- + +# Author + +**Pradeep Mishra** + +GitHub: **pradeep-code1** + +Project created as part of the **PyBe Summership** program to explore story-based learning for programming education. \ No newline at end of file diff --git a/summership-26-prs/Pradeep Mishra/assets/rajgad_welcome.jpg b/summership-26-prs/Pradeep Mishra/assets/rajgad_welcome.jpg new file mode 100644 index 0000000..dd75b24 Binary files /dev/null and b/summership-26-prs/Pradeep Mishra/assets/rajgad_welcome.jpg differ diff --git a/summership-26-prs/Pradeep Mishra/assets/step1_arrival.jpg b/summership-26-prs/Pradeep Mishra/assets/step1_arrival.jpg new file mode 100644 index 0000000..4aaf7ba Binary files /dev/null and b/summership-26-prs/Pradeep Mishra/assets/step1_arrival.jpg differ diff --git a/summership-26-prs/Pradeep Mishra/assets/step2_verification.jpg b/summership-26-prs/Pradeep Mishra/assets/step2_verification.jpg new file mode 100644 index 0000000..5b9469a Binary files /dev/null and b/summership-26-prs/Pradeep Mishra/assets/step2_verification.jpg differ diff --git a/summership-26-prs/Pradeep Mishra/assets/step3_durbar.jpg b/summership-26-prs/Pradeep Mishra/assets/step3_durbar.jpg new file mode 100644 index 0000000..a2cca94 Binary files /dev/null and b/summership-26-prs/Pradeep Mishra/assets/step3_durbar.jpg differ diff --git a/summership-26-prs/Pradeep Mishra/assets/step4_ledger.jpg b/summership-26-prs/Pradeep Mishra/assets/step4_ledger.jpg new file mode 100644 index 0000000..7bab2b8 Binary files /dev/null and b/summership-26-prs/Pradeep Mishra/assets/step4_ledger.jpg differ diff --git a/summership-26-prs/Pradeep Mishra/index.html b/summership-26-prs/Pradeep Mishra/index.html new file mode 100644 index 0000000..d5d27d9 --- /dev/null +++ b/summership-26-prs/Pradeep Mishra/index.html @@ -0,0 +1,1436 @@ + + + + + + PyBe Discovery Lab: The Gates of Rajgad + + + + + + + +
+
+
+ + +
+ +
+ Rajgad Fort at golden hour +
+
+
⚔️
+
🏰
+
🛡️
+
📜
+
+
🏔️ PyBe Discovery Lab · Season I
+

The Gates of
Rajgad

+

1665 CE — Sahyadri Mountains, Maharashtra

+

राजगड किल्ल्याचे द्वार

+
+

+ Follow Subedar Yesaji Kank — the legendary guardian
+ of Rajgad — and discover the secret of Python Decorators. +

+ +
+
▼  Begin the Journey
+
+ + +
+
+ Messenger arrives at Maha Darwaja +
+
+
Step 1 of 5 · The Problem
+

The Maha Darwaja — Gates of Rajgad

+
+
+
+
+
+ ⚔️ +
+
Subedar Yesaji Kank
+
Supreme Guardian · Rajgad Fort · 1665 CE
+
+
+
+
📜 The Scene
+

+ "Late afternoon. A royal messenger arrives at the iron-spiked gates. + Subedar Yesaji Kank stands firm — hand on his shamsher sword. + The messenger shouts urgency. + The gate does not move." +

+
+
+
+
+
🚪 The Decision
+

What does Subedar Kank do?

+
+
+

The messenger insists his news is urgent. Subedar Kank's response:

+ + +
+ + + +
+
🐍 How this maps to Python
+

+ A Python Decorator is exactly like Subedar Kank. + When you call a function, the decorator runs its BEFORE check first — + before your function even starts. You cannot skip it. + Just like the gate cannot open before Kank's verification. +

+
+ +
+
+
+ + +
+
+ Yesaji Kank checks the copper mudra token +
+
+
Step 2 of 5 · Before Phase
+

The Copper Mudra — Verified

+
+
+
+
+
+ 🔐 +
+
The Pre-Check Protocol
+
Before Any Gate Opens · No Exceptions
+
+
+
+
📜 Subedar Kank Acts
+

+ "Kank holds the copper Mudra to the light. He breaks the wax seal. + He checks every mark against the Royal Seal of Swarajya. + Only then does his hand move toward the bolt." +

+
+
+
+
+
🛡️ Before Phase
+

Why check before opening?

+
+
⬡  PHASE: BEFORE
+
+

What does Subedar Kank's pre-check achieve?

+ + +
+ + +
+
🐍 How this maps to Python
+

+ This is the BEFORE phase of a Python Decorator. + The code inside the decorator that runs before calling your function — + like checking if a user is logged in, logging the start time, or validating inputs. + Kank's Mudra check = decorator's before-code. +

+
+ +
+
+
+ + +
+
+ Messenger delivers scroll to Shivaji Maharaj +
+
+
Step 3 of 5 · Main Function
+

The Royal Durbar — Mission Executed

+
+
+
+
+
+ 📜 +
+
The Core Mission
+
One Task · One Purpose · No Deviation
+
+
+
+
📜 The Gates Open
+

+ "Subedar Kank nods. The iron bolt slides. The messenger kneels before + Chhatrapati Shivaji Maharaj and delivers the scroll — + his one sacred task. Nothing more. Nothing less." +

+
+
+
+
+
📜 Main Function Phase
+

Execute the Core Task

+
+
⬡  PHASE: MAIN TASK
+
+

The messenger has one pure purpose. Press to execute it:

+ +
+ MESSENGER + MAHARAJ + 📜 +
+ +
+
🐍 How this maps to Python
+

+ The messenger's scroll delivery = your actual function — the one you wrote with def deliver_message():. + The decorator doesn't change what the function does. + It just runs BEFORE and AFTER it. + The MAIN TASK stays pure. +

+
+
+ +
+
+
+ + +
+
+ Yesaji Kank writes in the Rojkird +
+
+
Step 4 of 5 · After Phase
+

The Rojkird — Every Exit Recorded

+
+
+
+
+
+ 📋 +
+
The Post-Mission Log
+
After Every Mission · The Record Stands
+
+
+
+
📜 Subedar Kank Writes
+

+ "Mission complete. The messenger turns to leave. + Subedar Kank opens the Rojkird. + Token number, entry time, exit time — all recorded. + After every mission, the record is eternal." +

+
+
+
+
+
📋 After Phase
+

Why log after the task?

+
+
⬡  PHASE: AFTER
+
+

Subedar Kank records the exit. What does this achieve?

+ + +
+ + + +
+
[EXIT LOG · RAJGAD FORT · 1665 CE · 4th Prahara]
+ Messenger: Vitthal Deshpande · Token #: 0x4A7C
+ Entry: Chaitra 12 · Exit: +20 min
+ Mudra ✓ · Scroll ✓ · Exit Safe ✓
+ — Subedar Yesaji Kank, Guardian of Rajgad +
+
+
🐍 How this maps to Python
+

+ The Rojkird log = the AFTER phase of a Python Decorator. + Code that runs after your function completes — + logging execution time, saving results, sending notifications, cleaning up resources. + Kank's exit log = decorator's after-code. +

+
+ +
+
+
+ + +
+
+

⚔️ The Python Connection

+

See how the Rajgad story maps exactly to Python Decorators

+ + +
📐 Story → Code — Side by Side
+
+ + +
+
+
🛡️ Story — BEFORE
+
Kank checks the Mudra token before the gate opens
+
+
+
+ # runs BEFORE your function
+ print("Before") +
+
+ + +
+
+
📜 Story — MAIN TASK
+
Messenger delivers the scroll to Maharaj
+
+
+
+ # your actual function runs here
+ result = func() +
+
+ + +
+
+
📋 Story — AFTER
+
Kank logs the exit in the Rojkird after the mission
+
+
+
+ # runs AFTER your function
+ print("After") +
+
+
+ +
+
💻 The Complete Code — Simple & Clean
+
+
+
+ rajgad_security.py +
+
+
1def security(func):
+
2    def wrapper():
+
3        print("Before")  # 🛡 Kank checks Mudra — BEFORE
+
4        result = func()  # 📜 Messenger delivers — MAIN
+
5        print("After")   # 📋 Kank logs Rojkird — AFTER
+
6        return result
+
7    return wrapper
+
8 
+
9@security  # ← Appoints Subedar Kank as guardian
+
10def deliver_message():
+
11    print("Delivering message")
+
12    return "Done"
+
13 
+
14deliver_message()  # Kank's full protocol runs automatically!
+
+
+ +
+
+
+ Terminal — rajgad_security.py +
+
+
$ python rajgad_security.py
+
Before
+
Delivering message
+
After
+
>>> 'Done'
+
+
+ +
+
📚 The Big Picture — What This Story Taught You
+
+
+
🛡️
+
Kank = the Decorator
+
Just like Subedar Kank runs his protocol around every mission, a decorator runs its code around every function call — automatically.
+
+
+
📜
+
@security = "Assign Kank"
+
Writing @security above a function is like assigning Subedar Kank to guard it. From now on, Kank's protocol runs every time you call that function.
+
+
+
⚔️
+
Always: Before → Task → After
+
Kank checks first, then the messenger delivers, then Kank logs the exit. Python decorators follow this same order — every single time.
+
+
+ +
+ + +
+
+
+ + +
+
+
+
🏆 Final Quiz · Question 1 of 3
+
+
+
+
+
+

+ In the story, Subedar Kank checks credentials before the gate opens. + In Python, what plays the role of Subedar Kank? +

+
+
+ + + + +
+ + +
+ + +
+
+
+ + +
+
+
+
🏆 Final Quiz · Question 2 of 3
+
+
+
+
+
+

+ The messenger's job was to deliver the scroll — nothing more. + In Python code, what is the equivalent of this scroll delivery? +

+
+
+ + + + +
+ + +
+ + +
+
+
+ + +
+
+
+
🏆 Final Quiz · Question 3 of 3
+
+
+
+
+
+

+ Subedar Kank wrote in the Rojkird after the mission ended. + In the code below, which line is the "Rojkird" entry? + + print("Before")  →  func()  →  print("After") + +

+
+
+ + + + +
+ + +
+ + +
+
+
+ + +
+
+
+
🏆
+

+ Rajgad is Yours! +

+

+ You have walked through all five gates, witnessed Subedar Kank's protocol,
+ and mastered the three phases of a Python Decorator. +

+
+
+
🛡️
+
BEFORE
+
Kank checks the Mudra
+
+
+
📜
+
MAIN
+
Scroll delivered to Maharaj
+
+
+
📋
+
AFTER
+
Kank logs in the Rojkird
+
+
+ +
+
+ +
+ + + + +