Skip to main content

Posts

Showing posts from November, 2018

Getting Started With Python (4) - Mathematics's Order, Comparison, and Logical of Operation

Order of Operations In mathematics operation, we should solve it in the following order : parentheses, exponents, multiplication, division, addition, and subtraction; which known as PEMDAS. It is important to know the proper order as it crucial for getting the correct answers when coding programs. where such operations are performed. Let's try using IDLE : Enter the following command :                         5+3*2 When you press ENTER , the result is 11. It is obvious that multiplication part comes first (3*2) and then adding 5, which result is 11. Let's try again with open another file from IDLE. On above examples there are two kind, which are : 5-3*2 and (5-3)*2 The results of the two statements above will be : Let's try other examples with exponent : There are two additional examples using exponential, 5^3*2 and 5^(3*2). The result between that two are : Comparison Operation We will try to practice about comparison operations, which co

Getting Started With Python (3) - Mathematics Operation

In this section, we will do some work on mathematical operation which are multiplication, division, addition, subtraction, modulus, exponent, and floor division . You might want to look at my previous post , it has some example of mathematics operations (arithmetic and algebra). On the editor window of Python, enter the following : a=35 b=22.78  Let's add these a and b together using the addition operator. For the recommendation practice, may we add a comment before the lines of code  #Addition print(a+b) print() Using subtraction operation : #Subtraction print(a-b) print() Save the file, run the module ( Run>Run Module ) or press F5 . The output will be : Next, we go with multiplication and division : #Multiplication print(a*b) print() #Division print(a/b) print() Save the file and run the file again, you will get the following output : Other operation that we will try is modulus , which is denoted by % sign. Modulus operator