Friday, May 25, 2018

python chap 8 (Hi friends this is the continuation of previous post so i kindly request you to read that before this post. As this blog is also prepared for beginners so i advice you that you don't need to by-heart this lessons just read and understand it if you have any doubt ask in the comment section)

PYTHON OPERATORS

The other operators are Comparison operators: a = 10 and b = 30
  •  ( == ) equalto : here we put a == b if a is equal to b it will return true otherwise false so here it will return false
  • ( != ) not equal to , here we put a != b if a is not equal to b then it will return true so here it will return true
  • ( < ) less than , here we put a < b if a is less than b then it will return true other wise false so here it will return true
  •  ( > ) greater than, here we put a > b if a is greater than b then it will return true otherwise false so here it will return false 
  • ( >= ) greater than or equal to , here we put a >= b if a is greater than or equal to b then it will return true otherwise false so here it will return false
  •  (<=) less than or equal to : here we put a <= b if a is less than or equal to b then it will return true otherwise it will return false so here it will return true
Assignment operators
  • ( = ) Equal to assignment : c= a+b here c is assigned the value of a+b
  • ( += ) ADD AND : here we put as 10+= 5 by adding the two values 10 and 15 return 15
  • ( -= ) Subtract AND: here we put 10 -= 5  by subtracting 5 from 10 return 5
  • (  *= ) Multiply AND : here we put 10* = 5  by multiplying 5 and 10 returns 50
  • ( /= ) Divide AND: here we put 10 / = 5  by dividing  10 by 5 returns 2
  • (% = ) Modulus AND:here we put 21 %= 10 by modulus 21 and 10  and returns the coefficient is1
  • (**=) Exponent AND:here we put 2**=4 is 2 to the power of 4 returns 16
  • (//=) Floor Division: it is the same as a//=b is the same as a//b as explained earlier
Bit Wise Operators
The bitwise operators are which works on bits and performs bit by bit operation as simple computers knows only 0 and 1 the binary language. A bitwise operations operates on one or more bit patterns or binary numerals at the level of there induvidual bits it is a fast simple action supported by the processor and is used to manipulate values for calculation and comparison her are some examples given as  a = 50
b = 25 the binary of this numbers is
a =0011 0010
b= 0001 1001
the operations can be done as 
  • a & b = 16 binary is 0001 0000 : It is a binary AND operator here operator copies a bit to the result if it exists in both operands
  • a | b = 59  binary is  00111011: It is a binary OR operator It copies a bit if it exists in either operand
  • a ^ b = 43 binary is  0010 1011: It is a binary XOR operator It copies the bit if it is set in one operand but not both
  • ~a = -51 is the ones complement it is unary and has the effect of flipping the bits 
  • Binary Left shift operator << :the left operands value is moved by the number of bits specified by the right operand : a << 1 = 100 here a is 50
  • Binary Right shift operator the left operands value is moved right by the number of bits specified by the right operand : a >> 1 = 25 here a is 50

More on operators like logical operators will be discussed on the next section hope you understand this lesson if you have any doubts please comment below and to get latest lessons and updates on this lessons don't forget to follow by email or follow me and don't forget to share and comment your suggestions below

No comments:

Post a Comment