Skip to main content

break, continue, and pass in Python पायथन में, `ब्रेक`, ` कंटिन्यू`, और `पास`

In Python, `break`, `continue`, and `pass` are control flow statements used in for and while loops and conditional if-else.

पायथन में, `ब्रेक`, ` कंटिन्यू`, और `पास` नियंत्रण प्रवाह के कथन हैं जिनका उपयोग फॉर और व्हाइल लूप और कंडीशनल इफ-एल्स में किया जाता है।

1.) break statement:- It Exits the loop immediately, regardless of the iteration count or condition. It is commonly used to stop a loop when a certain condition is met.
1.) ब्रेक स्टेटमेंट:- यह पुनरावृत्ति गणना या स्थिति की परवाह किए बिना तुरंत लूप को समाप्त कर देता है। इसका उपयोग आमतौर पर एक निश्चित शर्त पूरी होने पर लूप को रोकने के लिए किया जाता है।

Syntax:-

 break

Example:-

for i in range(5):

  if i == 3:

     break

  print(i)

Output:-

0
1
2

2.) continue statement:- It skips the rest of the code inside the loop for the current iteration and moves to the next iteration. It is Useful when we want to skip certain conditions in the loop but continue iterating.
2.) कंटिन्यू कथन: - यह वर्तमान पुनरावृत्ति के लिए लूप के अंदर शेष कोड को छोड़ देता है और अगले पुनरावृत्ति पर चला जाता है। यह तब उपयोगी होता है जब हम लूप में कुछ शर्तों को छोड़ना चाहते हैं लेकिन पुनरावृत्ति जारी रखते हैं।

Syntax:-

  continue

Example:-

for i in range(5):

  if i == 3:

    continue

  print(i)

Output:-

0
1
2
4

3.) pass statement:- It does nothing. It's a placeholder that lets you define a code block syntactically but without any operation. It is Useful in places where syntactically, a statement is required but you don't want to execute any code yet for example during development of program.
3.) पास स्टेटमेंट:- यह कुछ नहीं करता है। यह एक प्लेसहोल्डर है जो आपको बिना किसी ऑपरेशन के कोड ब्लॉक को वाक्यात्मक रूप से परिभाषित करने देता है। यह उन जगहों पर उपयोगी है जहां वाक्यविन्यास की दृष्टि से, एक कथन की आवश्यकता होती है लेकिन आप अभी तक किसी भी कोड को निष्पादित नहीं करना चाहते हैं, उदाहरण के लिए प्रोग्राम के विकास के दौरान।

Syntax:-
  pass 

Example:-

for i in range(5):

  if i == 3:

    pass # Placeholder

  print(i)

Output:-

0
1
2
3
4

Comments

Popular posts from this blog

Programming with Python Language Tutorial available in hindi and english पाइथन प्रोग्रामिंग टुटोरिअल हिंदी एवं अंग्रेजी भाषा में

 Unit -01 1. Introduction to python (पाइथन भाषा का परिचय) 2. History of Python Programming Language पाइथन प्रोग्रामिंग लैंग्वेज का इतिहास 3. Python Programming Language’s Features and Advantages पायथन प्रोग्रामिंग लैंग्वेज की प्रमुख विशेषताएं 4. Python’s Programming Language's Popularity पाइथन प्रोग्रामिंग लैंग्वेज की लोकप्रियता 5.The Future of Python Programming Language पायथन प्रोग्रामिंग लैंग्वेज का भविष्य 6. The Python Interpreter पायथन इंटरप्रेटर 7. The Python IDLE पाइथन आईडीएलई 8. Installation process of Python IDLE पायथन आईडीएलई की इंस्टालेशन प्रक्रिया 9. Dynamically typed and strongly typed features of python गतिशील रूप से टाइप और दृढ़ता से टाइप की गई भाषा पायथन 10. Basic Data Types of Python पायथन के बेसिक डेटा टाइप 11. Variables in python पायथन में वेरिएबल 12. Expressions in Python पायथन में अभिव्यक्तियां 13. Statements in Python पायथन में कथन 14. Operator's in Python पायथन में ऑपरेटर्स 15. Flow of execution of a python program पाइथन प्रोग्राम के निष्पादन का प्रवाह 16...

Inbuilt Functions in Python पाइथन में अंतर्निहित फ़ंक्शन्स

Python is a powerful programming language that provides many inbuilt functions to make coding simple and efficient. These functions help programmers perform common tasks like finding length, converting characters, or checking memory addresses without writing extra code. पायथन एक शक्तिशाली प्रोग्रामिंग भाषा है जो कई अंतर्निहित (inbuilt) फ़ंक्शन्स प्रदान करती है, जिससे कोडिंग आसान और प्रभावी हो जाती है। ये फ़ंक्शन प्रोग्रामर को सामान्य कार्य करने में मदद करते हैं जैसे लंबाई निकालना, अक्षरों का रूपांतरण करना या मेमोरी एड्रेस जांचना, और इसके लिए अतिरिक्त कोड लिखने की आवश्यकता नहीं होती। (a)  id()  – Unique Identifier of an Object  किसी वस्तु का अद्वितीय पहचानकर्ता The  id()  function returns the unique memory address of an object. Every variable or object in Python is stored in memory, and  id()  helps us know where exactly it is stored. id()  फ़ंक्शन किसी ऑब्जेक्ट का अद्वितीय मेमोरी एड्रेस लौटाता है। पायथन में हर वेरिएबल या ऑब्जेक्ट मेमोरी में संग्रह...

Conditional statements in Python if, if-else, if-elif-else पायथन में सशर्त कथन

  In Python, conditional statements help you make decisions in the code. There are three main types of conditionals:- पायथन में, सशर्त कथन आपको कोड में निर्णय लेने में मदद करते हैं। सशर्त के तीन मुख्य प्रकार हैं:-  1.) Conditional `if` statement:- An `if` statement executes the code block only if the condition evaluates to `True`. 1.) सशर्त `if` कथन:- एक `if` स्टेटमेंट कोड ब्लॉक को केवल तभी निष्पादित करता है जब स्थिति सही पर मूल्यांकन करती है। Syntax:- if condition:    Statement(s) Example:- x = 10 if x > 5:     print("x is greater than 5") 2.) Alternative `if-else` statement:  An `if-else` statement checks a condition and executes a block of code('if' block), if the condition is true otherwise provides an alternative block of code ('else' block), if the condition is false. 2.) वैकल्पिक `if- else` कथन:- एक `if-else` स्टेटमेंट एक शर्त की जाँच करता है और कोड के एक ब्लॉक ('if' ब्लॉक) को निष्पादित करता है, यदि स्थिति सही है अन्यथा कोड का एक वैकल्पिक ब्ल...