Skip to main content

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 displays the remainder of a division operation.

Let's try with below examples :
#Modulus
print(8%4)

We will see 0 on the displayed shell window, because 8/4 doesn't have a remainder.

Let's try again :
print(9%4)

After saving and running the file, the result will of 1 will be appeared on the shell window, because 9 divided by 4 is 2 remainder 1.

Let's try other example :
print(15%6)

The result will be 3, since 15 divided by 6 is 2 remainder 3.


Next, let's try on exponential operation.
Exponentiation raises a number to the power of another number. The resulting number is known as the exponent.
Example, 2 raised to the 3rd power, or 2*2*2, is 8
In Python, the operation will be :
print(2**3)

Let's try other example :
print(12**2)

The result in the shell window will be :

Another operation to discuss is Floor Division or Integer, which symbolize by 2 forward slashes (//).
Floor division displays the product of a division operation as a rounded down number.

Let's try this operation :
print(9//4)

You will get 2 on the result. This is because 9 divided by 4 is 2, when rounded down.

We can also type the command as follow :
print(int(9/4))

Which get the same result as INT function is rounded the nearest whole number.

Other example :
print(20//6)
or
print(int(20/6))

The result shown on the shell window will be 3. This is because 20 divided by 6 is 3, not counting the remainder.


How to write code that not just show the result only, but also the statements :




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...