•  In python, we have the assignment operator
  • Definition: The assignment operator is used to assigning a value to variables.
  • eg:x=100
  • Here we just assign a value of 100 to the x variable.
  • we use the '"="  symbol to assign the values to the variables.
  • After assigning the values to the variables it performs the different types of operations.
  • The assignment operator mixed with another operator is called compound operator.
  • The different types of compound operators are:
  1. +=       
  2. -=      
  3. *=     
  4. /=      
  5. %= 
  6. //=    
  7. **=   
  8. &=
  9. |=
  10. ^=
  11. >>=
  12. <<=

Example: write a python program  using assignmnet operators.

  1. x=5
  2. x+=5
  3. print(x)
  4. 10
  5. x=2
  6. x-=2
  7. print(x)
  8. 0
  9. x=2
  10. x*=12
  11. print(x)
  12. 144
  13. x=10
  14. x/=5
  15. print(x)
  16. 2.0
  17. a=4
  18. a%=2
  19. print(a)
  20. 0

















Instance Of Java

We will help you in learning.Please leave your comments and suggestions in comment section. if you any doubts please use search box provided right side. Search there for answers thank you.
«
Next
Newer Post
»
Previous
Older Post

No comments

Leave a Reply

Select Menu