Skip to main content

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 compare two values in Python.

In the IDLE, please type the following :
     a=8
     b=8
Then, test for its equality using the statement :
     a==b
(Note : equality symbolize by 2 equal signs (==)joined together)
When you press ENTER, Python will answer it with True, as the value of a and b are the same/equal.

Let's change the value of a to 5
     a=5
If we type a==b again, Python will answer it with False, since a=5 and b=8.


If we want to try compare two numbers if they are non-equal, we can use statement !=
Enter the following in the IDLE shell :
     a!=b
As a=7 and b=9, the answer will be True

Instead of !=, we can use < or > which are more familiar.
Let's try this :
     23>21
Then press ENTER. Since 23 is greater than 21, the answer is True.
Other trial :
     25>31
Then press ENTER. Since 25 is lesser than 31, the answer is False.

Let's try with combination between less than or greater than with equal sign.
Example : 15<=15
With that above example, the answer is True
Other example :
     15<=17
This will show answer True, as 15 is lesser than 17.


There is also combination the assignment operation with addition and subtraction operations, using the following symbols :
     += and -=

Let's try to get better understanding.
Type a =10 and b=15
As the value of b is 15, if we enter b+=5, it will add 5 to b, which mean that new value of b is 20.
Then, a+b, or 10+20, the result will be 30.

For the minus sign, as current value of b is 20, if we enter b-=8, the new value of b is 12.
If we subtract a from b (a-b), the result is -2.


Logical Operation
There are three logical operations in Python, which are : and, or, and not.

Run the IDLE Python and let's type some example :

     (5==5 and 18==18)
When we press ENTER, the result is True, since both statements (5==5 and 18==18) are true. And operation need that both statements, to be true to return True.

     (5==5 and 18<17)
In above example, 5==5 is true but 18<17 is false. The result is False since one of the statement is false.

Let's try with three statements :
     (5==5 and 18==18 and 18>17)
Since all three statements are true, it will also result in True.
Other example :
     (5==5 and 18==18 and 18<17)
In the case above, as one of the statements are false, it will result False.

Other logical operation is Or.
On the shell IDLE, enter the statement :
     (5==5 or 18<17)
On above operation, 5==5 is true but 18<17 is false. Since only one statement is required to be true when using Or operation, this statement is true.
     (5==5 or 18>19 or 18<17)
In that sample above, regardless of the number of statements, the or operator will always return True, as long as one of the statements is true.

Last logical operator, Not, which its will goes before the statement.
Example :
     not(8==8)
This will result False, since not negates the value of statement. Since 8==8 is true, put not before the statement make it false.
     not(7==8)
That will result True, since 7==8 is false but negates by not.










Comments

Popular posts from this blog

Satellite Communication - Part 4 (CPI)

Cross Polar Isolation (CPI) In installation and pointing/peaking antenna, Orthogonal Mode Transducer (OMT) must be set to be as precise as possible to get the best CPI value. above is picture of OMT Feed assembly include with BUC and LNB The minimum value for CPI is 30 dB (better will be good) in Linier Polarized Antennas. The reason is for our receive (Rx)-side as not to get interferenced (distrubed) by other (polarity) Down-Link users, therefore our transmit (Tx) shoild as well not interfere other users that operates at 90 deg (Orthogonal) Polarization. Note : In LH/RH Circular Polarizations, usually CPI of 27dB (=AR of 1.09) is acceptable enough. picture above is careless/miss-aligned OMT setting

Satellite Communication : Transmission Bands

A satellite link is a radio link between a transmitting earth station and receiving earth station through a communications satellite. A satellite link consists of one uplink and one downlink; the satellite electronics (i.e., the transponder) will remap the uplink  frequency to the downlink frequency. The transmission channel of a satellite system is a radio channel using a direct-wave approach, operating in at specific RF bands within the overall electromagnetic spectrum as seen below : The table below shown some key of physical parameters of relevance to satellite communication,  The frequency of operation is in the super high frequency (SHF) range (3-30 GHz). Regulation and practice dictate the frequency of operation, the channel bandwidth, and the bandwidth of the subchannels within the larger channel. Different frequencies are used for the uplink and for the downlink. Frequencies above about 30 MHz can pass through the ionos...

Satellite Communication - Part 1

In this occasion, i want to share about Satellite communication. First, please look at the picture below, Planets of our Solar System God created Moon as our Earth satellite. In order to broading our communication, people tend to use artificial satellite for communication. Based on orbits, these are the type of satellites : Low Earth Orbit (LEO)              Height : 750-2500 Km,       Period : 2 - 2.5 hours Medium Earth Orbit (MEO)       Height : 7500-10000 Km,   Period : 4.5 - 6 hours High Earth Orbit (HEO)             Height : 15000-20000 Km, Period : 11-12 hours Geo-Stationary Orbit (GSO)      Height : 36000 Km,             Period : 24 hours Incline Orbit Satellite (drifting > 0.1 deg. N-S an...