Table of Contents All Chapters 1. Classes and Objects 2. Class in Python 3. Class Structure 3.1. Attributes...
- Table of Contents
- All Chapters
Table of Contents
Conditional Statements in Python in Hindi
What is Conditional Statements in python in Hindi
python में decision making के लिए If-else conditional statement का use करते हैं, यह specific conditions के basis पर code के different block को execute करते हैं, if-else का use करके हम program के flow को dynamically control कर सकते हैं.
How if-else work
What is If Statement in Hindi
यह condition को check करता है अगर condition true हुई तो if block execute हो जाता है अगर condition true नहीं हुई तो if block का execution नहीं होता है
num = 10
if num > 5:
print("Number is greater than 5")
else:
print("Number is 5 or less")
# Output: Number is greater than 5
What is Else Statement in Hindi
अगर if condition false होती है तो else block का execution होता है.
इसे एक Example se समझते हैं
num = 5
if num > 5:
print("Number is greater than 5")
else:
print("Number is 5 or less")
# Output: Number is 5 or less
What is Elif Statement in Hindi
python में multiple condition को check करने के लिए elif statement का use करते हैं जब एक से ज्यादा conditions को sequencely check करना होता है तो इसका use किया जाता है
How elif works :
इसका use if and else के बीच में किया जाता है हम अपने जरूरत के हिसाब से multiple elif का Use करते हैं अगर if condition false हो जाती है तो elif block का execution होता है अगर हमने अपने program में एक से ज्यादा elif का use किया है तो जो condition सही होगा उस elif block का execution होगा
इसे एक example के through समझते हैं :
num = 5
if num > 5:
print("Number is greater than 5")
else:marks = 75
if marks >= 90:
print("Grade: A")
elif marks >= 75:
print("Grade: B")
elif marks >= 50:
print("Grade: C")
else:
print("Grade: F")
# Output: Grade: B
print("Number is 5 or less")
# Output: Number is 5 or less
What is Nested if-else in Hindi
जब हम किसी if condition के अंदर भी कोई condition check Karte Hain तो इसे nested if else कहते हैं
age = 20
has_id = True
if age >= 18:
if has_id:
print("You can vote")
else:
print("You need an ID to vote")
else:
print("You are too young to vote")
# Output: You can vote
What is Ternary Operator in Hindi
अगर python में हम conditional expression को एक लाइन में लिखने चाहे तो Ternary operator का use करना होता है इसमें value और condition और statement एक ही लाइन में लिख सकते हैं जैसा की syntax में दिया गया है
आइए इसे एक example की help समझते हैं
num = 10
result = "Even" if num % 2 == 0 else "Odd"
print(result)
# Output: Even
उम्मीद करते है कि आपको conditional statements in python अच्छे समझ मे आ गया होगा । अपने learning को continue रखने के लिए next button पर click करे,
- All Posts
- Artificial Intelligence
- Computer Fundamentals
- Computer Networks
- Data Analytics
- Data Science
- DBMS
- Deep Learning
- Digital Fundamentals
- DSA with Python
- Excel
- Exercise
- Git & Github
- Machine Learning
- Matplotlib
- Natural Language Processing
- NumPy
- Operating System
- Pandas-s
- Power BI
- Python Tutorial
- Scikit-learn
- Seaborn
- SQL & MySQL
Table of Contents All Chapters 1. Python Function 2. Define Function 3. Function Arguments 4. Function Parameters 5. Local and...
Table of Contents All Chapters 1. Python Dictionary 2. Access Dictionary items 3. Change Dictionary items 4. Add items in...
Table of Contents All Chapters 1. Python Set 2. Iterate Set items 3. Set Methods 3.1. Add items...
Table of Contents All Chapters 1. Python Tuple 2. Access Tuple Items 3. Update Tuple 4. Iterate Tuple Items 5....
Table of Contents All Chapters 1. Python List 2. Nested List 3. Range List 4. List Indexing 5. list Methods...
Table of Contents All Chapters 1. Python String 2. String Indexing 3. String Slicing 4. String Concatenation 5. String Formatting...
Table of Contents All Chapters 1. Python Loops 2. While Loop 2.1. Nested While Loop 3. For Loop...
Table of Contents All Chapters 1. If-else Statements 1.1. If Statement 1.2. Else Statement ...