DAY 46 — 60 DAY PYTHON CHALLENGE
Hospital Management
Python mein Hospital Management banao — Hindi mein step by step
Advertisement
Project kya hai?
Day 46 ka project hai Hospital Management!
Yeh project banane se aap Python ke important concepts
practice kar payenge. Neeche complete code hai — copy karo aur chalao!
Complete Python Code
python — hospital.py
class Patient:
def __init__(self, pid, name, doctor, disease):
self.pid = pid
self.name = name
self.doctor = doctor
self.disease = disease
self.discharged = False
class Hospital:
def __init__(self, name):
self.name = name
self.patients = []
self.next_id = 1
def admit(self, name, doctor, disease):
p = Patient(self.next_id, name, doctor, disease)
self.patients.append(p)
self.next_id += 1
print(f"Patient admit hua! ID: {p.pid}")
def discharge(self, pid):
for p in self.patients:
if p.pid == pid:
p.discharged = True
print(f"{p.name} discharge ho gaye!")
return
print("Patient nahi mila!")
def show_active(self):
active = [p for p in self.patients if not p.discharged]
print(f"\n=== Active Patients ({len(active)}) ===")
print(f"{'ID':4} {'Naam':15} {'Doctor':12} {'Bimari'}")
print("-" * 50)
for p in active:
print(f" {p.pid:2} {p.name:13} Dr.{p.doctor:9} {p.disease}")
def report(self):
total = len(self.patients)
active = sum(1 for p in self.patients if not p.discharged)
discharged = total - active
print(f"\n=== {self.name} Report ===")
print(f" Total Admitted : {total}")
print(f" Active Patients : {active}")
print(f" Discharged : {discharged}")
h = Hospital(input("Hospital naam: "))
while True:
print("\n1. Patient admit karo")
print("2. Patient discharge karo")
print("3. Active patients dekho")
print("4. Report dekho")
print("5. Baahar jao")
ch = input("Choice: ")
if ch == "1":
h.admit(input("Patient naam: "), input("Doctor naam: "), input("Bimari: "))
elif ch == "2":
h.discharge(int(input("Patient ID: ")))
elif ch == "3": h.show_active()
elif ch == "4": h.report()
elif ch == "5": break
OUTPUT
Hospital naam: City Hospital Choice: 1 Patient naam: Ravi Doctor naam: Sharma Bimari: Bukhar Patient admit hua! ID: 1 === Active Patients (1) === ID Naam Doctor Bimari -------------------------------------------------- 1 Ravi Dr.Sharma Bukhar
Code kaise kaam karta hai?
Auto-increment ID se har patient unique hota hai. Boolean discharged flag se status track hoti hai. Report mein statistics clearly dikhti hain.
Advertisement
📋 Project ka Introduction
Hospital Management Python ka Day 46 ka project hai. Is project mein aap Python ke important concepts practice karenge jo real-world applications mein bahut use hote hain.
Yeh project beginners ke liye design kiya gaya hai lekin kaafi concepts cover karta hai. Step by step samjho, code chalao, aur khud modify karke practice karo.
Is tarah ke projects banane se aapka Python confidence badh jaata hai aur aap asli problems solve karna seekh jaate hain. Chaliye code samjhte hain!
Yeh project beginners ke liye design kiya gaya hai lekin kaafi concepts cover karta hai. Step by step samjho, code chalao, aur khud modify karke practice karo.
Is tarah ke projects banane se aapka Python confidence badh jaata hai aur aap asli problems solve karna seekh jaate hain. Chaliye code samjhte hain!
🧠 Is Project mein kya seekhoge?
Yeh project banate waqt aap ye Python concepts use karoge:
| Concept | Kya karta hai |
|---|---|
Variables | Data store karna |
Functions | Reusable code blocks |
Loops | Repeat karna |
Conditions | Decisions lena |
Input/Output | User se interact karna |
📝 Code kaise kaam karta hai — Step by Step
Neeche code ki poori logic step-by-step samjhayi gayi hai:
- Problem samjho: Hospital Management mein kya karna hai
- Required variables aur data structures decide karo
- Logic step-by-step likhó
- Code mein implement karo
- Test karo aur bugs fix karo
⚠️ Common Mistakes — Bhool mat jaana!
Beginners yeh galtiyan aksar karte hain — dhyan rakho:
- ⚠️ Indentation sahi rakho — Python mein spaces matter karti hain
- ⚠️ Variables ko use se pehle define karo
- ⚠️ Input ko int()/float() mein convert karo agar number chahiye
- ⚠️ Edge cases handle karo — kya hoga agar user galat input de?
🏋️ Practice Exercises — Aage badho!
Yeh project complete karne ke baad in exercises se practice karo:
- 💡 Hospital Management mein naya feature add karo
- 💡 Code ko functions mein refactor karo
- 💡 Error handling improve karo
- 💡 File mein data save karo
❓ Aksar Pooche Jane Wale Sawal (FAQ)
Q: Hospital Management project kyon banana chahiye?
A: Har project ek naya concept sikhata hai. Practice se hi Python fluent aati hai.
A: Har project ek naya concept sikhata hai. Practice se hi Python fluent aati hai.
Q: Code run nahi ho raha?
A: Indentation check karo, syntax errors dekho, variables define hain ya nahi check karo.
A: Indentation check karo, syntax errors dekho, variables define hain ya nahi check karo.
Q: Kaise improve karein?
A: Pehle basic version complete karo, phir ek ek feature add karte jao.
A: Pehle basic version complete karo, phir ek ek feature add karte jao.