Python tutorial |
Python tutorial: First steps with python
Hello friend, welcome to another python tutorial, this time you will make your first steps with python, and you will learn about math operators,
in this tutorial we will work with python IDLE, so let us start
first here are Math Operators:
math operators |
Math with python: addition, subtraction, multiplication and division
python IDLE can be a calculator, so enter the following expressions into the interactive shell to see for yourself:math with interactive shell |
as you see the interactive shell is a calculator ^_^ , even if we give it a complicated expression it will calculate it , let us try:
complicated math expression for interactive shell |
now let us take a look on other operators:
** exponent
% Modulus/remainder
// integer division
to understand each one of them we use examples,
Exponent:
a**b = a*a*a*...... b time3**4 = 3*3*3*3 four times
exponent |
Modulus:
a%b = the rest of division a/b16%7 =2 because 16 = 7 * 2 + 2
modulus |
Integer division :
a//b= the integer part of the a/b7//2=3 because 7/2=3.5 and the integer part is 3
integer division |
this is the end of this python tutorial, i hope that you enjoyed it and learn something new
don't forget to practice
thanks
if i missed something i will be pleased to hair from you in the comments below