
As we mentioned before, I am going to use python 2.X instead of version 3.X. Even if you have installed Python, you won’t need it for now. First, let’s learn the rules/syntax using Codeacademy’s python 2. You can the app on your phone or the computer.
I might give commands to the computer using python but how to get to hear from the computer? The print command. In front of the print, you can add what you want the computer to return/output. For E.g. writing the code below will return only the words inside the quote marks after running the code.
Typed on the editor: Input NB: The function/argument print starts with small letters.
print "Learning Bioinformatics Algorithms"
Seen in the console after running: Output
Learning Bioinformatics Algorithms
Anything denoted using quote marks is a string – either ” or “”. This can even be added like below.
print "Hello " + "Sarah"
Hello Sarah
Did you notice the space after hello? If it wasn’t there, the result would have been
HelloSarah
january_to_june_rainfall = 1.93 + 0.71 + 3.53 + 3.41 + 3.69 + 4.50
annual_rainfall = january_to_june_rainfall
september_rainfall = 5.16
october_rainfall = 7.20
november_rainfall = 5.06
december_rainfall = 4.06
sep_dec_rainfall = 5.16 +7.20 +5.06 +4.06
annual_rainfall+=sep_dec_rainfall
Note Normally, when integers are divided, they will return an integer result even when the result has a decimal point by rounding it. If you want to keep the decimal, you can do so by adding float in the operation or putting a decimal point in one of the numbers.
cucumbers=100
num_people=6
whole_cucumbers_per_person= 100/6
print whole_cucumbers_per_person
float_cucumbers_per_person =100./6
print float_cucumbers_per_person
quotient1 = float(7)/2
# the value of quotient1 is 3.5
Did you notice the symbol used to assign values to variables? =
That’s about it. However, the best thing to do is to go through everything by yourself. However, if you know the things below, you can good to proceed to the next blog.
- Print statements
- How to create, modify, and use variables
- Arithmetic operations like addition, subtraction, division, and multiplication
- How to use comments to make your code easy to understand
- Different data types, including strings, ints, floats, and booleans
Converting between data types

A scientist who writes about her daily experiences. Most are drafts but some are publicly shared, like this one you just read.