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 चे प्रकार

| Statement | Description |
|---|---|
| if statement | एक condition check करते |
| if else statement | दोन conditions handle करते |
| if elif else | multiple conditions check करते |
| nested if | if statement आत दुसरे if |
| ternary operator | one-line condition |
Python if Statement काय आहे?
Python if statement म्हणजे condition true असेल तर code execute करणारा statement.
Syntax:
if condition:
code
Simple Example:
temperature = 35
if temperature > 30:
print(“It is a hot day”)
Output:
It is a hot day
Real-Time Example: Website Login Access
समजा website वर login करताना user active आहे का ते check करायचे.
user_active = True
if user_active:
print(“Login Successful”)
Output:
Login Successful
Python if else Statement काय आहे?
Python if else statement condition true किंवा false असताना वेगवेगळा code run करतो.
Syntax:
if condition:
code
else:
code
Example:
number = 7
if number % 2 == 0:
print(“Even Number”)
else:
print(“Odd Number”)
Output:
Odd Number
Real-Time Example: ATM Withdrawal System
ATM मध्ये balance पुरेसा आहे का ते check करतात.
balance = 5000
withdraw = 3000
if withdraw <= balance:
print(“Transaction Successful”)
else:
print(“Insufficient Balance”)
Output
Transaction Successful
Python if elif else Statement काय आहे?

Python if elif else statement multiple conditions check करण्यासाठी वापरतात.
Syntax:
if condition1:
code
elif condition2:
code
else:
code
Example:
marks = 82
if marks >= 90:
print(“Grade A”)
elif marks >= 60:
print(“Grade B”)
else:
print(“Grade C”)
Output:
Grade B
Python Conditional Statements – Real-Time Example: Student Result System
School system मध्ये marks नुसार grade दिले जातात.
marks = 72
if marks >= 90:
print(“Excellent”)
elif marks >= 60:
print(“Good”)
elif marks >= 40:
print(“Pass”)
else:
print(“Fail”)
Output:
Good
Python Nested if Statement काय आहे?
Nested if statement म्हणजे if statement च्या आत दुसरा if statement वापरणे.
Example:
age = 22
has_license = True
if age >= 18:
if has_license:
print(“You can drive”)
Output:
You can drive
Python Conditional Statements – Real-Time Example: Job Eligibility Check
Job portal मध्ये age आणि degree दोन्ही check करतात.
age = 24
degree = True
if age >= 21:
if degree:
print(“Eligible for Job”)
Eligible for Job
Python Ternary Operator काय आहे?
Ternary operator म्हणजे if else statement एकाच line मध्ये लिहिण्याची पद्धत.
Syntax:
value_if_true if condition else value_if_false
Example
age = 17
result = “Adult” if age >= 18 else “Minor”
print(result)
Output:
Minor
Python Conditional Statements – Real-Time Example: E-commerce Discount Check
Online shopping website वर discount eligibility check करतात.
cart_value = 1500
discount = “10% Discount Applied” if cart_value >= 1000 else “No Discount”
print(discount)
Output:
10% Discount Applied
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:
password = “admin123”
if password == “admin123”:
print(“Login Successful”)
else:
print(“Wrong Password”)
Python Conditional Statements Best Practices
Python conditional statements लिहिताना:
- Condition readable ठेवा
- Logical operators वापरा
- Unnecessary nested if टाळा
- Clean code लिहा
Example:
if age >= 18 and citizen:
print(“Eligible to Vote”)
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 तयार करू शकतो.


