Operator Functions in Python-Set 1:

There are many mathematical, logical, relational, etc. operations predefined in Python under the module “operator”. Below are some of the functions in this module that we use in Python for Data Science:

  1. add(a,b) – This functions performs addition of two arguments i.e. a + b.
  2. sub(a,b) – This function returns the difference of the two arguments provided i.e., a-b.
  3. mul(a,b) – This function returns the product of two arguments i.e., a*b.

Operator Functions in Python for Data Science Set 1 - PST Analytics

  1. truediv(a,b) –
  2. This function is used to find the division of two arguments i.e., a/b
  3. floordiv(a,b) – This is also used to perform division but the value returned is floor value which is the highest small integer. It is denoted by a//b.
  4. pow(a,b) – This function performs exponentiation of the arguments and return the value. It is denoted by a**b.
  5. mod(a,b) – This performs modulus operation on the arguments and returns the value. Its operation is a%b.

Operator Functions in Python for Data Science Set 1 - PST Analytics

  1. lt(a,b) –
  2. This is a function used for checking whether a is less than b or not. If a<b, then it returns TRUE otherwise FALSE.
  3. le(a,b) – This is a function used for checking whether a is lesser than or equal to b or not. If a <= b then it returns TRUE otherwise FALSE.
  4. eq(a,b) – This is a function used for checking whether a and b are equal or not. It returns TRUE if a and b are equal and returns FALSE otherwise.

  1. gt(a,b) – This is a function that is used for checking whether a is greater than b or not. If a is greater than b then it returns TRUE, otherwise returns FALSE.
  2. ge(a,b) – This is a function that is used for checking whether a is greater than or equal to b. It returns TRUE if a >= b otherwise returns FALSE.
  3. ne(a,b) – This is a function used for checking whether a is equal or not equal to b. It returns TRUE if a not equal to b otherwise returns FALSE.

If you want to learn more about python for data science then you can check this and this.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.