Python Conditional Statements – Python Fundamental

Python Conditional Statements म्हणजे program मध्ये condition (अट) true किंवा false असल्यावर कोणता code execute करायचा हे ठरवणारे statements.

Python मध्ये मुख्य conditional statements:

  • if statement
  • if…else statement
  • if…elif…else statement
  • Nested if statement
  • Ternary Operator

हे statements decision making आणि control flow साठी वापरले जातात.

Python Conditional Statements म्हणजे काय?

Python Conditional Statements program ला logical decision घेण्याची क्षमता देतात.

उदाहरण:

  • जर user 18 वर्षांपेक्षा मोठा असेल → account create करा
  • जर user 18 पेक्षा कमी असेल → account reject करा

यामुळे program smart decision घेऊ शकतो.

Python Conditional Statements चे प्रकार

Python Conditional Statements चे प्रकार
StatementDescription
if statementएक condition check करते
if else statementदोन conditions handle करते
if elif elsemultiple conditions check करते
nested ifif statement आत दुसरे if
ternary operatorone-line condition

Python if Statement काय आहे?

Python if statement म्हणजे condition true असेल तर code execute करणारा statement.

Syntax:

Simple Example:

Output:

Real-Time Example: Website Login Access

समजा website वर login करताना user active आहे का ते check करायचे.

Output:

Python if else Statement काय आहे?

Python if else statement condition true किंवा false असताना वेगवेगळा code run करतो.

Syntax:

Example:

Output:

Real-Time Example: ATM Withdrawal System

ATM मध्ये balance पुरेसा आहे का ते check करतात.

Output

Python if elif else Statement काय आहे?

Python if elif else Statement काय आहे?

Python if elif else statement multiple conditions check करण्यासाठी वापरतात.

Syntax:

Example:

Output:

Python Conditional Statements – Real-Time Example: Student Result System

School system मध्ये marks नुसार grade दिले जातात.

Output:

Python Nested if Statement काय आहे?

Nested if statement म्हणजे if statement च्या आत दुसरा if statement वापरणे.

Example:

Output:

Python Conditional Statements – Real-Time Example: Job Eligibility Check

Job portal मध्ये age आणि degree दोन्ही check करतात.

Output:

Python Ternary Operator काय आहे?

Ternary operator म्हणजे if else statement एकाच line मध्ये लिहिण्याची पद्धत.

Syntax:

Example

Output:

Python Conditional Statements – Real-Time Example: E-commerce Discount Check

Online shopping website वर discount eligibility check करतात.

Output:

Real-World Applications

Python conditional statements खालील systems मध्ये वापरले जातात:

  • Login Authentication System
  • ATM Banking Software
  • E-commerce Discount System
  • Student Result Management
  • AI Decision Systems
  • Form Validation

Example:

Python Conditional Statements Best Practices

Python conditional statements लिहिताना:

  • Condition readable ठेवा
  • Logical operators वापरा
  • Unnecessary nested if टाळा
  • Clean code लिहा

Example:

Python Conditional Statements FAQ

Q1. Python Conditional Statements म्हणजे काय?

Ans: Python Conditional Statements म्हणजे program मध्ये condition check करून decision घेण्यासाठी वापरले जाणारे statements.

Q2. Python मध्ये किती Conditional Statements आहेत?

Ans: मुख्य conditional statements:

  • ternary operator
  • if
  • if else
  • if elif else
  • nested if

Q3. Python conditional statements real world मध्ये कुठे वापरतात?

Ans: Python conditional statements वापरतात:

  • AI automation
  • Login system
  • ATM transaction
  • Student grading system
  • E-commerce discount logic

Conclusion

Python Conditional Statements program ला smart decision making capability देतात.

हे statements वापरून आपण:

  • Login systems
  • Banking software
  • AI automation
  • Web applications

सारखे powerful applications तयार करू शकतो.

Scroll to Top