Arithmetic Operators and their special usage
1).
If we go
through this program:-
Output:-
a.
According to ‘+’
operator result will be 14.
b.
But in Python this input
function gives the values in string.
c.
If gives values in string
then ‘+’ operator acts as a concatenation (merge them).
d.
To overcome from this
problem, we need to typecast the input function.
So, we type caste input function by an integer, you can also
use float, double etc.
Output:-
a.
Now, we come through the
desired output.
b.
We can do same as for
subtraction, multiplication and division also.
2). But in division there is one thing.
If we do a / b approach, then we get float values.
If we do a
// b approach, then we get integer values.
3).
Output:-
In this
example program, ** operator means a raise to the power b.
4).
Output:-
In this example program, % operator
gives the remainder.
Author - Tushar Srivastava

Comments
Post a Comment