Skip to main content

14.1 Python Assignment operators

ASSIGNMENT OPERATORS 
Assignment operators are used to assign values to variables. 
Eg:
a=1909 

The Assignment Operators are listed as follows: 
  • ( = ) :assigns a value to a variable 
  • (+=) :adds right operand to the left operand and assign the result to left operand 
  • (-=) :subtracts right operand from the left operand and assign the result to left operand 
  • (*=):multiply right operand from the left operand and assign the result to left operand 
  • (/=):divides left operand with the right operand and assign the result to left operand
  • ( %=):returns the remainder when left operand is divided by the right operand and assigns the result to the left operand. 
  • (//=) :divides left operand with the right operand and assign the floor value result to left operand. 
  • (**=):calculate exponent value using operands and assign the result to the left operand. 
  • (&=):performs AND on operands and assign value to left operand 
  • (|=):performs OR on operands and assign value to left operand 
  • (^=):performs bitwise XOR on operands and assign value to left operand. 
  • (>>=):performs bitwise right shift on operands and store values on left operand 
  • (<<=):performs bitwise left shift on operands and store values on left operand 
Program
a=5 
print("a=",a) 
a+=20 
print("a+=",a ) 
a-=15 
print("a-=",a) 
a*=10 
print("a*=",a) 
a/=2 
print("a/=",a) 
a%=99 
print("a%=",a) 
a//=3 
print("a//=",a) 
a**=4 
print("a**=",a) 
a=250 
a&=3 
print("a&=",a) 
a|=4 
print("a|=",a) 
a^=9 
print("a^=",a) 
a>>=2 
print("a>>=",a) 
a<<=9 
print("a<<=",a) 
Output
a= 5 
a+= 25 
a-= 10 
a*= 100 
a/= 50.0 
a%= 50.0 
a//= 16.0 
a**= 65536.0 
a&= 2 
a|= 6 
a^= 15 
a>>= 3 
a<<= 1536 
It is also possible assign values multiple variables using assignment operators
Program
a,b=5,6
print(a)
print(b) 
Output
a= 5 
b= 6
Visit the video below to learn about operators in detail!!
Happy Learning!!

Comments

Popular posts from this blog

Get Ethical Hacking Project #1

Thanks for your interest in our course This is a paid course, 150 rs for Indian people, 5$ for international people Instructions to get course: Indian people can get the course by paying using this UPI id   tamilhacks@ybl  (KARTHIKEYAN T) send 150 Rs to this upi id with subject bug bounty and after payment take a screenshot and send that to email id tamilhackstech@gmail.com - you will get the course within 24 hours. (there will be no tax, when paying using upi id)     The above mentioned method is most preferable. if you don't have a upi id app, install  phonepe  or  google pay   app and register there and pay easily  or  pay here using the alternate method to get this course, this link cost 18% gst for the course . (nearly 30-100 Rs for tax and other charges here )   After payment you will receive a payment confirmation mail along with a downlink for the course, you can download the course file using that . the course is in zip format, so after downloading the file extra

Learn c++ in Tamil | Complete guide and tutorial | Beginner to Advance all concepts explained.

hi guys welcome , all the coding used in video are available here : /* hi guys welcome to learn c++ in tamil what is C++ how what software your own program schools,clg,institute.... start 1.interest 2.patience 3.fun 4.practise computer program - app - programming source code - hardware - fb running , executing machine language :  101010 assembly lang : mov h1; high lang : c , c++....java , js , python  eg :  a+b .....1001010  compiler :  human to machine              machine to human  rules :  a+b;  usage:  games, manufacturing , embedded , finance , graphics , etc...  Guide: 1.problem 2.solution - alternative 3.program  - C++ 4.compile  - turboc , ide , codeblocks , cmd 5.result   - library file - linker : #include<iostream.h>    input , output std::cout<<"welcome";   standard character out << " "; primary section : 1.statements   ;  end 2.functions   main() 3.syntax  , syntax error pra

Get Bug Bounty Course

Thanks for your interest in our course Limited Offer This is a paid course, Rs 10000 ,Rs 1000  for Indian people, 75$ 15$ for international people , 50$ 10$ for Srilankan people Instructions to get course: Indian people can get the course by paying using this UPI id  tamilhacks@ybl  send 1000 Rs to this upi id with subject bug bounty and after payment take a screenshot and send that to email id tamilhackstech@gmail.com - you will get the course within 24 hours. (there will be no tax, when paying using upi id)    The above mentioned method is most preferable. if you don't have a upi id app, install phonepe or google pay   app and register there and pay easily  or  pay here using the alternate method to get this course, this link cost 18% gst for the course . (nearly 30-100Rs for tax and other charges here ) After payment you will receive a payment confirmation mail along with a downlink for the course, you can download the course file using that. As for international peopl