SIMPLE VALUES

The building Blocks.

Hey there, bioinformatics enthusiasts! Welcome back to another installment of our Python for Bioinformatics series. Today we’ll delve into the fundamentals of simple values in Python, including booleans, integers, floats, special values, and the ever-important strings.

Booleans

The boolean value (True or False), also known as logical values, forms the foundation of conditional statements in Python. As you may recall from exams, boolean values can be either True or False. You can just type True in the python shell and you will see that python recognises it. You can also check the type of this by using the type function.

Let’s take a closer look:

Python 3.11.7 (main, Dec  4 2023, 18:10:11) ß
Type "help", "copyright", "credits" or "license" for more information.
>>> True 
True

Then you can check the type of the bool.

>>> type(True)
<class 'bool'>

Remember, boolean values are case-sensitive in Python, so ensure correct spellings when using them in your code.

Integers

Integers represent whole numbers like 1,2,3,4,5…., including both positive and negative values. They are used extensively in various computations. Here’s how you can work with integers:

>>> 1
1

You can also check the class of the integers.

>>> type(1)
<class 'int'>

You can also enter a very huge integer like this:

>>> 1234531244038974908237
1234531244038974908237

You might have noted that commas and seprators (which are there to make the huge numbers more readable) are not used in python for integers.

Floats

Floats, short for floating point numbers (also known as Decimal Numbers), are used to represent decimal values or numbers in scientific notation. In Python, the term “float” refers to a data type used to represent decimal numbers (numbers with a fractional part).

Here’s a glimpse:

>>> 2.5
2.5

You can also check the type by using the type function:

>>> type(2.5)
<class 'float'>

Python automatically switches to scientific notation for extremely large float values.

>>> 123213123123123123123.12321329
1.2321312312312313e+20

Special Values

The special value None denotes the absence of a value, often used to indicate missing data in datasets. If you will type None in the python shell and hit enter you will not get back any thing like you used to get with other types. See the code example below:

>>> None
>>>

We will see how and where None can be used in later videos.

Strings

Strings play a crucial role in bioinformatics, especially when dealing with DNA, RNA, or protein sequences. They are enclosed within single quotes, double quotes, or triple quotes for multiline strings:

>>> "Python for Bioinformatics"
'Python for Bioinformatics'

Lets take a look at the protein sequence:

>>> 'MKMDLMK'
'MKMDLMK'

Lets take a look at the DNA sequence:

>>> "ATGCTCTCGTCGACGACDAT"
'ATGCTCTCGTCGACGACDAT'

Strings enable us to represent and manipulate textual data efficiently, making them indispensable in bioinformatics workflows.

Next we will be talking about Expressions.