Loop
Loop एक ऐसी Programming Technique है जिसके द्वारा किसी एक ही Code को बार-बार (Repeatedly) चलाया जाता है, जब तक कोई निश्चित Condition पूरी होती रहती है।
Types of Loops in Hindi
- For Loop
- While Loop
- Do-while Loop
1. For Loop
forLoop एक Control Statement है जो किसी Sequence के प्रत्येक Element को एक-एक करके पढ़ता है और हर Element के लिए Loop के अंदर लिखा Code चलाता है।- for loop का use sequence के element को iterate करने के लिए किया जाता है | for loop का use कोई भी sequence के सभी element को display करने के लिए किया जाता है | sequence यह list, double, dictionary और string होता है
- जब iteration start होता है तब variable पर sequence का element assign किया जाता है और दिए गए statement को execute किया जाता है | जितने element की संख्या होती है उस संख्या तक iteration होता रहता है और उसके बाद loop का control loop के बाहर आ जाता है |
Syntax :
for variable in sequence
for_statement(s)
Source Code :
a = [5, 6, 9, 8, 5, 7]
for n in a :
print(n)
Program explain :
for→ Loop शुरू करता है।n→ एक Variable है, जिसमें हर बार नया Element आएगा।-
in→ List के अंदर से Value लेने के लिए। a→ वह List जिस पर Loop चल रहा है।
2. While Loop
- While Loop एक ही statement को बार-बार execute करता रहता है | जब तक condition true होती है तब तक statement execute होते रहती है और जब condition false हो जाती है तब loop का iteration stop हो जाता है |
Syntax :
while (expression):
while_statement(s)
Source Code :
a = 0
while (a < 10) :
print("Value a is ", a)
a = a + 1
Program Explain :
aनाम का Variable बनाओ और उसमें0रख दो।- जब तक
aकी value10से कम है, तब तक नीचे वाला कोड बार-बार चलाओ। - स्क्रीन पर
"Value a is"औरaकी वर्तमान (Current) value दिखाओ। aकी पुरानी value में1जोड़कर नई valueaमें रख दो।
3. Do-while Loop
do...whileLoop एक Exit-Controlled Loop है, जिसमें पहले Loop के अंदर का कोड कम से कम एक बार चलता है, उसके बाद Condition चेक की जाती है। यदि ConditionTrueहोती है, तो Loop दोबारा चलता है, और यदिFalseहोती है, तो Loop समाप्त हो जाता है।
Syntax :
while True:
# Statements
if not condition:
break
Source Code :
a = 1
while True:
print("Value of a =", a)
a = a + 1
if a > 5:
break
Program Explain :
aनाम का Variable बनाया गया और उसकी Value 1 रखी गई।- जब तक True है, तब तक Loop चलता रहेगा।
- यह
aकी वर्तमान वैल्यू स्क्रीन पर दिखाता है। - यह
aकी वैल्यू में 1 जोड़ देता है। - यह जांचता है कि क्या
aकी वैल्यू 5 से बड़ी है। यदि हाँ, - तो नीचे वाला
breakचलेगा। breakका अर्थ है
Loop को तुरंत बंद कर दो।
- Python Full Course Roadmap 2026Python Introduction↓Python Installation & Setup↓Python Basics↓Variables & Data Types↓Operators↓Conditional Statements↓Loops↓Functions↓Data Structures↓File Handling↓Exception Handling↓Object Oriented Programming (OOP)↓Modules & Libraries↓Advanced Python↓Database Connectivity↓Web Development↓Data Science & AI↓Automation & Projects↓Python Developer
- What is Python in Hindi (Basic to advanced)Introduction and History Introduction for Python Python History Python Features Python Applications Applications Uses 1. Artificial Intelligence (AI) and Machine Learning Python का उपयोग AI models, Machine Learning algorithms, Chatbots, Face Recognition, Voice Assistant और Prediction systems बनाने के लिए किया जाता है। 2. Data Science and Data Analysis Python से बड़े datasets को analyze… Read more: What is Python in Hindi (Basic to advanced)
- Python Keywords in Hindi (easy to understand )Python Keywords में ऐसे special word होते हैं जिनका Python भाषा में पहले से एक Predefined meaning होता है। Python Interpreter इन words को पहचानता है और इनके अनुसार कार्य करता है। Example : No. Keyword हिंदी में अर्थ Uses (उपयोग) Syntax 1 False गलत False keywords का use Boolean False value के लिए किया… Read more: Python Keywords in Hindi (easy to understand )
- Python Variables in Hindi (Easy to understand)what is Variable Assigning Value to variable Source Code : Output : 5 Hello [2, 5, 9] Changing Variable’s Values Source Code : Output : 5Hello[4, 5, 8] Assigning Single Value to Multiple Variables Source Code : Output : HelloHelloHelloHello Assigning Value to Variable according to order Source Code : Output : 1H[1, 2] Variable… Read more: Python Variables in Hindi (Easy to understand)
- Python Data Types in Hindi (easy to understand)Python में Data Type यह बताता है कि किसी variable में किस प्रकार का data store है। Python में data type को manually declare नहीं करना पड़ता, Python interpreter value देखकर data type पहचान लेता है। Example : Number Python में Number Data Types का उपयोग संख्याओं (Numbers) को store और process करने के लिए… Read more: Python Data Types in Hindi (easy to understand)
