Introduction of Python
Getting Started with Python
Syntax in Python
Comment in Python
Variables in Python
Data Types in Python
Numbers in Python
Castings in Python
Strings in Python
Boolean in Python
Operators in Python
List in Python
Tuples in Python
Sets in Python
Dictionary in Python
if Else Statement in Python
While Loop in Python
For Loop in Python
Functions in Python
Lamba Function in Python
Arrays in Python
Classes and Objects in Python
Inheritance in Python
Iterators in Python
Scope in Python
Modules in Python
Dates in Python
Math in Python
JSON in Python
RegEx in Python
Try and Except in Python
User Input in Python
String Formatting in Python
Python Boolean
Python me Boolean ka concept same waisa hi hai jaisa ki baki languages me hota ha. Boolean “True” aur “False” or “1” or “0” ki value ko signify karta hai.
print(19 > 18)
print(19 == 18)
print(‘apple’ == ‘apple’)
Python me Boolean almost har ek conditions me applicable hota hai. Yah mainly If…else loop, while loop, for loop aur bhi aise conditional statements ke sath use karke “True” or “False” ki condition ko check karta hai. Example se samajhte hain:
x = 500
y = 57
if y > x:
print(“y is bigger than x”)
else:
print(“y is not bigger than x”)
O/P : y is not bigger than x
Dekha jaye to upar diye gaye example me ‘if’ condition boolean ki hi “True” or “False” ki properties ko follow kar raha hai, jaha condition ki value False hai aur wah output bhi uske according hi print kar raha hai.
Python Boolean me ek Bool() function bhi use kiya jata hai, jise apply karke hum “True” or “False” ki condition ko check kar sakte hain… jaise:
print(bool(“Python”))
print(bool(25))
print(bool(23 == 45))
O/P : True ; True ; False
Bool() function ka use karne par most of the value “True” hi hoti hain, jaise ki aap upar diye gaye example me dekh sakte hain aur aap ye bhi dekh rahen hoge ki jaise hi humne bool functon ka use karke 2 numbers par condition apply kar diya waise hi interpreter ne condition ke hisab se apna output bhi print kar diya hai joki False hai.
Kuch condition jisme bool ki value false hoti hai…
bool(())
bool([])
bool({})
bool(0)
bool(“”)
bool(False)
bool(None)
Function ke sath Boolean ka use:
Kisi bhi Function me mostly boolean ka use hota hi hai kyuki coding ke case me kisi na kisi condition ko apply karna hi hota hai.
Chhote se example se samajhte hain jaha myFoo() ek function defined hai jo call hone par “True” value dega. To jaise hi hamne ise if statement ke sath call kiya waise hi ye “True” condition ko pakar apna output bhi print kar dega.
def myFoo() :
return True
if myFoo():
print(“Condition is True”)
else:
print(“Condition is False”)
O/P : Condition is True
Kuch Naya Jane : Most rated No code Database Software 2021 | No Code Tool for Database Management in 2021