How to write a Python program for taking input from user for implementing assignment operators on it?

How to write a Python program for taking input from user for implementing assignment operators on it?


First you have to take input from user by input command and for testing assignment operator you have to typecast it into an integer and after this I just wanted to tell that Assignment operators in python assign a value in a variable , like to add a digit in a variable's value which is an int , or adding a digit using assignment operator in a variable's value which is entered by the user for doing this here is a code for and example --

x=int(input("Enter your number"))
x+=5
print("After adding 5 in your number-",x)
#after this we can also do subtraction from the entered number entered by the user
x-=5.
print("After subtracting 5 from your number-",x)

One thing which is to be remembered is that after using "x-=5" it will change the real digit 
which is stored in the variable.
For example if you enter 10 in the input in the code which I have given here it will first
first print 15 and in second line it will print 10, because first it will add 5 then value of x will
become 15 and after subtracting 5 , it will become 10 once again.
Hope this will help you a bit.👍👍

Comments

Popular posts from this blog

Shopping Bill Generator In python.

Should we start preparation for BCA/MCA from class 11th ? How ?

Python program to check that a list have elements in it or not .