100% de satisfacción garantizada Inmediatamente disponible después del pago Tanto en línea como en PDF No estas atado a nada 4.2 TrustPilot
logo-home
Resumen

Samenvatting commando's Python - Bio informatica (B-KUL-U09B1B)

Puntuación
-
Vendido
-
Páginas
5
Subido en
10-02-2025
Escrito en
2023/2024

Dit is een samenvatting van alle commando's gebruikt op Python, samen in één document. Commando en wat het doet staat duidelijk geschreven. Er staan ook voorbeelden in van hoe een bepaald commando te gebruiken.

Institución
Grado









Ups! No podemos cargar tu documento ahora. Inténtalo de nuevo o contacta con soporte.

Escuela, estudio y materia

Institución
Estudio
Grado

Información del documento

Subido en
10 de febrero de 2025
Número de páginas
5
Escrito en
2023/2024
Tipo
Resumen

Temas

Vista previa del contenido

Commando’s python
1. Go to jupyter notebook  log in
a. String = sequence of characters
b. Error: SyntaxError (eg. No “”) & NameError (eg. prin > print)

Print(‘x’) Printing a message to the screen
Print(“x”) x = argument
Print(“he said, ‘x’”)
Print(‘he said, “x”’) The function print() can take either a string or
a number (integer) as argument
#comments A comment will be ingored by the computer
\n New line
\t Tab
my_dna = “ATGC” Assigning a string (“ATGC”) to a variable
(my_dna) = Giving a name to something
print(my_dna) Output: ATGC
print(“my_dna”) Output: my_dna
Variable name are arbitrary Rules:
- Only letters, numbers and underscore
- Can not start with a number
- Con not use a word that is built in to
the Python language, eg. print
- Case sensitive
+ Concatenating string
My_dna = “AATT” + “GGCC”
Print (My_dna) Output: AATTGGCC
Upstream = “AAAA”
My_dna = upstream + “ATGC”
Print(My_dna) Output: AAAAATGC
The result of concatenating strings is itself a
string
len(“x”) Length of a sequence

dna_length = len(“AGTC”) (of
len(“varable”) Output: 4
print(dna_length) The return value of len() is a number (an
integer)
You can not use strings & integers mixed up in the same command: functions str() and
int()
str() String (argument)

Vb. print(“AT content is “ + Output: AT content is 4
str(at_content))
 at_content is a number Integer to string: when you need to
concatenate or format numbers as part of a
string
int() Integer (number)

Vb. int(‘4’) Int(expression) als expression een getal is

Vb. number = 3 + int(dna_length)
Print(number) Output: 9 (if dna_length = len(“AATCGA’) = 6)

, String to integer: when you receive numerical
input as a string and need to perform
numerical operations
Only usable with variables that are strings – methods that belong to the string type
x.lower() Lowercase
print(my_dna.lower()) Doesn’t change the variable, they
return an copy
x.upper() Uppercase
print(my_dna.upper()) Doesn’t change the variable, they
return an copy
x.replace(“x”,”y”) Replacing x by y

print(protein.replace(“v”,”y”) It returns a copy of the variable where
all occurrences of the first string are
replaced by the second string
Extracting part of a string (taking a substring)
x[1:6] Number 1 until 5 (incl. 1, excl. 6)
- Position starts at zero
- Inclusive start
- Exclusive stop
x[0:] From begin to end
Counting substring
x.count(‘y’) In take 1 argument (the substring), it returns
the number of occurrences of the substring in
the string
Vb. my_dna.count(‘X’) We will count how many times X is in the
variable ‘my_dna’
x.find(‘y’) Finding substrings
It takes 1 argument (the substring), it returns
the position of the first occurrence of the
substring in the string
vb. protein.find(‘p’) We will find the position where ‘p’ stands the
first time in the variable ‘protein’
- Of the output is -1: ‘p’ is not in protein
- The positions start counting at zero
Order of count() and find()
My_dna.count(“A”) ≠ A.count(my_dna)

Working with files
open(“x.txt”) Opening a file
- Argument = string
Vb. data_file = open(“data_2024.csv”)
NOT: my_file_name = “dna.txt”
My_contancts = #fout: read() werkt niet op strings
my_file_name.read()

NOT: print(data_file) #fout: print het bestandobject, niet de inhoud
x.read() Read the contents of the file
- x = file objects (not name of variable)
dna_file = open(“dna.txt”)
my_dna = dna_file.read()
x.rstrip(“y”) To remove a character
- my_file_contents = my_file.read()
my_dna = my_file_contents.rstrip(“\n”)
$8.71
Accede al documento completo:

100% de satisfacción garantizada
Inmediatamente disponible después del pago
Tanto en línea como en PDF
No estas atado a nada

Conoce al vendedor
Seller avatar
margauxvanw

Conoce al vendedor

Seller avatar
margauxvanw Katholieke Universiteit Leuven
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
0
Miembro desde
9 meses
Número de seguidores
0
Documentos
7
Última venta
-

0.0

0 reseñas

5
0
4
0
3
0
2
0
1
0

Recientemente visto por ti

Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes