Skip to main content

Featured

Write a Python Program to find palindrome of a given string

If you reverse the word then you get the same word that word is palindrome. def   palindrome ( str ):     pointer =  str       rev_str =  reversed (pointer)       if   list (pointer) ==  list (rev_str):         print ( "It is palindrome" )       else :         print ( "It is not palindrome" )  palindrome( 'level' ) palindrome( 'madam' ) palindrome( 'life' ) palindrome( 'refer' ) Output:  It is palindrome It is palindrome It is not palindrome It is palindrome

Operators 3

Logical Operator:
                
                    Logical operators are used to combine or connect or comparison

OPERATORS:

  Or         atleast one has to be true
  And      Both have to be true
  Not       Negates the input

Lets look at some explanation:
      
 True or True-->True
 True or False-->True
 False or False-->False

 True and False-->False
 True and True-->True
 False and False-->False

not True-->False
not False-->True

Example:(run this in python shell)


Logical Operator:



Membership Operator:

               Membership Operator are very important when it comes to sequence. We use them to check if an element is a member of sequence but also to iterate over sequence.

             Membership Operator are in and not in. In this we check if a sequence contain a certain element. If the element is in sequence it returns true or else false 

            We also use membership Operator in for Loop (loops will be explained in future post)

Example:

List = [10,20,30,40,50]    //list is always enclosed by square brackets
Print(20 in list)
Print(60 in list)
Print(60 not in list)
Print(20 not in list)

Output:

Membership Operator


In next post lets see some interesting quiz!!


 
 

Comments

Popular Posts