Chapter 11 Varibles in Python
In Python, a variable is a reserved memory location to store values.
Unlike other porgramming languages, there is no command for declaring a variable.
When you assign a value to a variable,
= 100
gene_len = 25
GC_number = GC_number/gene_len
GC_content print(GC_content)
## 0.25
= 100
distance = 105
distance print(distance)
## 105
A variable can be a string.
= "AGCTAGCTAGTCAGCGATCGT"
DNA_seq print(DNA_seq)
## AGCTAGCTAGTCAGCGATCGT
Python has built in functions than can be used on the variables.
= "AGCTAGCTAGTCAGCGATCGT"
DNA_seq = len(DNA_seq)
DNA_length print("The length of the DNA is: ")
## The length of the DNA is:
print(DNA_length)
## 21
11.1 Variable names
There are certain rules you need to follow when you name a variable:
Must start with a letter (
gene_expr
) or underscore character (_gene1
).Only alphabetical and numeric characters and underscores can be oncluded (e.g. gene1_tpm).
Variable names are case-sensitive (
Gene1
andgene1
are two different variables)