Hello coding lovers,
In this blog, we will learn what variables and data types are in Python, why they are important, and how to practice them with a small bioinformatics project at the end.
But first, tell me how you are feeling after writing your first Python code? I hope it gave you confidence and motivation. If you haven’t seen my first blog on running your first Python code, check it here.
Table of Contents
What Are Variables and Data Types in Python?
Have you ever called someone by their name? Of course — we all do. 😄
Now imagine if you had no name. How would people identify you? It is our names that make us unique.
The same idea applies to Python variables.
Variables in Python are like names or labels we assign to data types (like numbers, text, or sequences) so we can store and access them easily later.
Example with simple data:
container1 = 'Qurat'
container2 = 'blogger'
Here, container1
and container2
are variables (labels).
Whenever I want to access 'Qurat'
. I can simply call container1
instead of typing 'Qurat'
again.
Understanding Variables with Bioinformatics Example
Now let’s relate it to bioinformatics, our core field!
Imagine you are working with DNA and RNA sequences.
Instead of copying long sequences repeatedly, you can store them in variables.
Example:
dna_sequence = 'ATCGTACGGA'
rna_sequence = 'AUCGAUCGGA'
gene_name = 'TP53'
dna_sequence
is a variable storing a DNA sequence.rna_sequence
stores an RNA sequence.gene_name
stores the name of a gene.
Now, anytime we want to analyze or manipulate these sequences, we just call their variable names!
Rules for Naming Python Variables
When assigning names to variables in Python (whether it’s simple data or biological data), follow these rules:
- Variable names can contain letters, numbers, and underscores (
_
). - A variable cannot start with a number.
- Variable names are case-sensitive —
gene_name
andGene_name
are different. - You cannot use reserved Python keywords like
if
,for
,while
, etc. (See here: Python keywords)
✅ Valid examples:
a = 3
_data = 'Write here'
full_name = 'Qurat-ul-ain'
dna_seq1 = 'ATCG'
❌ Invalid examples:
34name = 'invalid' # starts with a number
for = 45 # reserved word
gene/name = 'TP53' # contains /
What Is an Assignment Statement?
The assignment statement uses =
to assign a value to a variable.
Example:
gene_name = 'TP53'
Here, gene_name
is assigned the string 'TP53'
.

Project of the Day
Now, it is time to apply what you’ve learned by practicing and completing the project.
Project Task:
- Create 3 variables to store the following:
– Your favorite gene name
– A short DNA sequence
– A short RNA sequence - Print all 3 variables.
After completing your practice, please feel free to send your solved project to my email. I will definitely review it and will provide a detailed response.
In the next blog, we’ll learn how to use Python’s input function and basic string formatting.
Keep learning and keep exploring!