Skip to main content

PYTHON BASIC PROGRAMMING

These are some examples on basic commands and programming methods in Python.

N.B : I did it on my Raspberry Pi 3 and written on on Python 3

To putting text into the screen :

The # hash symbol means comment and Python will ignore everything that written after the hash - it is a way to add notes, reminder, or heading.
Result will be :
Arithmetic :
We can put two print commands into the same line using a ; semicolon. The second print command gives a line space between each equation.
You will notice that the answer for division sum includes decimal place.
Result


To remove the the decimal, we can use 'INT' function and answered number will be rounded to the nearest whole number,


With variables, we can get our program remember numbers and words, which we can use later.
and the result will be :

Variables can be words which called 'strings' because they are string of alphanumeric strung together.

Result will be :


The use of 'FOR LOOP' for counting in Python. In this example, the number (n)  starts at zero and increases to 10. Note that a +1 is need to be added, otherwise the loop will stop at 9.
Result will be :


Other example with different number and counting step,
The 'WHILE LOOP' continues until a certain criteria is met.
There are some situations where 'WHILE LOOP' are more suitable than 'FOR LOOP', usually in less predictable circumstances.
To achieve the incremental steps in counting, change the n+1 to higher number.
To counting in reserve,

Here is an example of 'WHILE LOOP' to keep generating random number until it find intended number.
The operator '!=' means'not equal to' , in other word, keep looping until find the number.

This example below creates something called a 'STRING ARRAY', which a list of separate words stored in variables.



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 ionosphere and

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 and E-W) Polar (mostly very eliptical) orbit satellite "in this purpose of satellite communication, I will focus in Geo-Stationary Orbit (GSO)" If we talk about GSO, we must mention this name, Arthur C. Clarke, a Science-Fictionist, which wrote : "a Satellite