Python Courses Notes
Python Courses Notes
Strings ("str" type object): variable que es texto. Sorrounded by quotation marks.
Each character in a string is assigned an index, starting with 0.
Functions, function()
print, displays output in screen
len, outputs length
str, convierte el objeto en str
input, reads a string
String concatenation:
el signo + me concatena strings, el * los repite
Si pongo numeros dentro del parentesis hacen referencia al orden de los argumentos
en .format.
Ej. : print('{1}{0}{3}'.format('de ','hijo ','nada','puta.') ====> hijo de puta
Format specification
print('{0:8} | {1:8}'.format('guacho','pistola')) ===> guacho |pistola
El 8 especifica la longitud del string que sale como output.
Para alinearlo, antes del 8 pones < (left), > (right), ^ (center)
NUMBERS
Data Type
f, es float
.Nf para los espacios decimales (especificados en N) de un numero.
int, es integer
FUNCIONES
def funcion():
describir lo que hace
def saludar(nombre):
print('Hola {}.'.format(nombre))
Los argumentos van en orden, o se puede especificar when you call a function, ej.:
def saludar(first,last):
saludar(last='Perro',first='Luki')
LISTS, LOOPS