Python Programming Tutorial – Membership Operators and Boolean operators


Hello guys and welcome to python programming
tutorials by amuls academy. Today in this class we are discussing about
membership operators and boolean operators in python programming language. First we will discuss about membership operators.There
are two membership operator in and not in.These membership operators are used to check whether
the given element is member of group of elements or not. Okey we will take some example so we will
understand better.i’ll take one element that is 5 and i will use membership operator in.Now
we need to check whether 5 is present in the group of element or not.Here i will use list. List is one of the fundamental concept in
python programming language.List is nothing but this is group of some element.i’ll type
2,3,4,5,6,7 now we are checking whether 5 is present in this group of element or not
so i will press enter we can see true because 5 is present here so we are getting answer
as true. Not in is exactly opposite to the in that
means it will check whether the element is present in the group if it is present it will
give answer as false if it is not present it will give answer as true. We will take same example 5 and i will use
not in and i will use list 2,3,4,5,6,7 and i will press enter we can see false because
5 is present here so it will give answer as false. Okey this is about membership operator. Next we will move to boolean operator there
are three and or not.Here and or is used to combine two or more statements.For example
56 and 5==5 it will give answer
as false eventhough this condition is true here this condition is false so it will give
answer as false. Here it will check first condition that is
5>6 this is false so it won’t check for next condition it will immediately give answer
as false.Because in and if any one of condition is false then the answer is false.Because
of this feature it is also called as short circuit evaluation or lazy evaluation. Okey this is about the and. Next we will discuss about or.or is also used
to combine two or more statements.But in the case of or if any one of the condition is
true then the answer is true.here we can see 57 or 6==6 answer is true
eventhough 6>7 is false this condition is true here so it will give answer as true.As
i said in or if any one of the condition is true then the answer as true. in or also it will check first condition if
it is true it won’t check next condition it will directly give answer as true.So this
is also called as lazy evaluation or short circuit evaluation. Third operator is not.not is used to reverse
the answer for example 10>5 yes it is true so we are getting answer as true.If you want
to reverse this answer then we can use not the answer is false. This is about boolean and membership opeartor
in python programming language thats it for now. thank you for watching i will meet you in
next class till then take care.

7 thoughts on “Python Programming Tutorial – Membership Operators and Boolean operators

  1. thank you man, ive been watchin lots of videos about the fundamentals and this series so far is the best one ive seen, hopefully it keeps gettin better

Leave a Reply

Your email address will not be published. Required fields are marked *