Sunday, July 12, 2020

Branching statement:

BRANCHING STATEMENT:

four type of Branching statement:

# 1. Simple if statement.

# 2. if.......else statement.

# 3. elseif ladder statement.

# 4. Nested if statement.

1.SIMPLE IF STATEMENT:
            1) In this evaluate process the condition must true  then only it will do next process.
            2)If  the condition is false there is nothing to happen automatically came out the process.
2.IF......ELSE STATEMENT:
          1)  If the condition is true it will do only one work.
          2)  If the condition is false it will do another work.
3.ELSE IF LADDER STATEMENT:
          3) It will be Executed  in step by step process and this process will 
                    be hope where the condition is true.
4. NESTED IF STATEMENT:
                In this condition having one if statement  itself  having another if statement on that.


Example:

SIMPLE IF STATEMENT:
        
a=5
if a==5:                              # Evaluate the condition is TRUE.
   print("welcome")

OUTPUT:
           welcome


2.IF......ELSE STATEMENT:

a=5
if a==4:
   print("welcome")
else:
   print("hello")                # Evaluate the condition is FALSE.

OUTPUT:
        hello



3.ELSE IF LADDER STATEMENT:

a=int(input("enter the value"))
if a==4:
   print("four")
elif a==5:
   print("five")                                                 
elif a==6:
   print( "six")                                                            
else:
   print("hello")     


OUTPUT:
  enter the value: 5
      five
enter  the value: 4                                             
      four

enter the value: 7                                  #we assing except this values automatically go to else part
       hello
                                                                                     and print hello

4. NESTED IF STATEMENT:

a=int(input("enter the value"))
b=int(input("enter the value"))
if a==4:
   if a>4:
      print('yes")
   else:
      print("no")
else:
   print("terminate")

OUTPUT:

      


            





Saturday, July 11, 2020

OPERATOR PRECEDENCE

OPERATOR PRECEDENCE:

()                                                -> Parentheses.

+x, -X, ~X                  -> Unary Plus, Unary minus,  Bitwise No.

**                                            -> Exponentiation (raise to the power).

* / % //                               -> Multiply, divide, Modulo, and Floor 
                                                                                                Division.

+ , -                                  -> Addition and Subtraction.

>>  <<                                 -> Right and Left bitwise .

&&                                         -> Bitwise  "AND"td.

^|                                               -> Bitwise exclusive "OR" and  regular "or".



Example:
        
e=(a+b)* c/d
                                                              #try this using in above the operator 
 e=a+(b*c)/d 
                                                                                precedence.
e=((a+b)*c)/d



       a,b,c,d=2,4,3,5

1.  e=(a+b)* c/d                           e=(2+4)*3/5     
        print(e)                                        e=(6)*3/5 
                                                                    e=18/5  
                                                                    Print(e)  
 OUTPUT:                             3.6                      
3.6

                                              
    2. e=a+(b*c)/d                                  e=2+(4*3)/5
         print(e)                                            e=2+(12)/5
                                                                         e=2+2.4
                                                                         print(e)
                                                                        4.4                                                                                                OUTPUT:          
     4.4
    
 3  e=((a+b)*c)/d
        print(e)
                                                  # YOU  TRY   ðŸ˜œðŸ˜œ                         
OUTPUT:
3.6