hello guys welcome to the second blog tutorial on Python programming for beginners in the last blog I have given you introduction to Python and I have shown you how you can install Python on your Windows operating system and I have given you a little example how you can use this pipe ide called idle for the first time okay so in this blog I am going to continue and I'm going to show you how you can use numbers and a mat in Python so if you are familiar with this last time I have shown you how to open this - shell right if you don't know how to open this shell once again I'm going to tell you we just need to go to your Start menu and just go to Python folder and just start this ideal Python GUI from here and it will open this kind of gooey shell or pythons shally here now let's get started and let's see how we can do math in Python so like a simple mathematics of Python can also do the maths for you so for example you want to add 5 plus 98 will give you the answer 1 0 3 euro you can even add minus values so minus 4 34 + 4 for example and give you an answer 30 okay in the same way you can do the subtraction cookies 56 minus 44 it will give you the answer and it will also give you the negative value if you provide them button value such as for example 44 minus 56 will give you the negative value okay now for division what you can do you can just write the following 21 / so this is the symbol we use for divisions which is slash for example 27 21 divided by 7 is 3 which gives you the answer and if you want to divide the number and get some decimal values for example 23 divided by 7 will give you 3 point 2 8 something right so this will also give you a decimal values now for example you don't want this these decimal values after the division you just want to see the full value or the integer what you can do we can just write 23 double slash 7 and this will give you the whole number which is 3 okay you can even so this this number is a integer and what is an integer integer is the whole number right you can even use decimal values which are called float in programming float values are values which have some decimal points for example 57 point 2 3 4 5 or whatever divided by 3 point 2 2 2 2 2 ok and press ENTER and will give you an answer so you can even divide decimal values like this okay and remember this whenever you want to get the whole number just use double slashes now for multiplication multiplication is also simple for example you want to multiply two number 56 multiply so for multiplication you use this asterisk symbol or star symbol simply so this star symbol or a stick symbol will be used as a multiplication symbol okay so 56 x 4 s 2 2 4 so you can use multiplication like this ok now for example and you want to get the F exponent of some what in what is an exponent exponent is something like for example 2 exponent 3 is 2 multiplied by 2 multiplied by 2 okay so 2 into 2 into 2 this is the exponent so you can do it like this and will give you the answer but if you want the exponent for example 2 to the power 15 how we can do you can do something like this two multiplied by two multiplied this but to multiply it by 2 multiplied by do 15 times and this will be lengthy right so the simple way to find the exponent is use double asterisks or double stars and then the power so 2 to the power 15 is 3 2 7 6 8 okay or 2 to the power 5 is 32 so this double star or double s takes which you can use to get the power or exponent of your numbers okay now you may be wondering what may be
the order of your operations which operation will take place when you have multiple multiple operation at the same time for example I want to do 3 x 4 plus 5 minus 6 and then divided by 1 or not 1 but 2 for example so what will be the order when 3 into 4 will happen first or 4 plus 5 will happen for a plug of 4 plus 5 it will happen first or 5 minus 6 will happen first or what is what will be the priority okay or what will be the order of this operation so like simple mathematic if you remember when you are in this school and or if you are in school still you know this basic formula called PE M da s ok so this is the order in which your operations will take place and this P stands for parentheses he stands for exponents M stands for multiplication d stands for division is stands for addition and s stands for subtraction ok and the way you remember this is you can just abbreviate it as please excuse my dear Aunt Sally if you want to remember this order ok and so this will be the priority or this will be the order of your operation so if you want to prioritize something and close the those operation in the parentheses so if you want to be 3 plus 4 and then multiplication or you want to multiply by 5 then the priority of this addition is the most important or this will happen first because this operation is enclosed in parentheses and then this will happen ok and then the the order will be like PE MDAs if you can remember so for example I want to do something like this divided by 6 minus 2 then the parentheses priority will be the first and then the multiplication and then the division and if you have some subtraction then this will happen and the last ok so in this way you can use numbers and math in your Python programs I hope you have enjoyed this blog
Post a Comment