PYTHON OPERATORS WITH PRACTICAL

PYTHON OPERATORS :


WATCH VIDEO FOR DETAIL EXPLANATION



     
Operators in general are used to perform operations on values and variables in Python. These are standard symbols used for the purpose of logical and arithmetic operations. In this article, we will look into different types of Python operators.


  1. Arithmetic operators: Arithmetic operators are used to perform mathematical operations like addition, subtraction, multiplication and division.
OperatorDescriptionSyntax
+Addition: adds two operandsx + y
-Subtraction: subtracts two operandsx - y
*Multiplication: multiplies two operandsx * y
/Division (float): divides the first operand by the secondx / y
//Division (floor): divides the first operand by the secondx // y
%Modulus: returns the remainder when first operand is divided by the secondx % y
**Power : Returns first raised to power secondx ** y



   EXAMPLE:  

  1. a = 9
    b = 4
      
    # Addition of numbers 
    add = a +
      
    # Subtraction of numbers 
    sub = a -
      
    # Multiplication of number 
    mul = a *
      
    # Division(float) of number 
    div1 = a /
      
    # Division(floor) of number 
    div2 = a //
      
    # Modulo of both number 
    mod = a %
      
    # Power
    p = a ** b
      
    # print results 
    print(add) 
    print(sub) 
    print(mul) 
    print(div1) 
    print(div2) 
    print(mod)
    print(p)




    OUTPUT :

    13
    5
    36
    2.25
    2
    1
    6561
    


     FOR MORE FOLLOW ME ON INSTAGRAM : @codeattraction 👇
    https://www.instagram.com/codeattraction/




















Comments

Popular posts from this blog

HANDWRITTEN NOTES (COMPUTER NETWORK ) USEFULL IN EXAMS (IMP TOPICS)

SESSION LAYER IN COMPUTER NETWORK

DATA STRUCTURE (IMP QUESTIONS )FOR (BE STUDENTS ,DIPLOMA STUNDENTS,UNIVERSITY) (CHEPTAR WISE )