Escrito por estudiantes que aprobaron Inmediatamente disponible después del pago Leer en línea o como PDF ¿Documento equivocado? Cámbialo gratis 4,6 TrustPilot
logo-home
Resumen

Summary Introduction to Python Codes

Puntuación
4.0
(1)
Vendido
11
Páginas
6
Subido en
25-05-2021
Escrito en
2020/2021

This contains relevant lines of codes and commands as well as examples for the material of Introduction to Python. This summary does not include theoretical or conceptual parts. This document might be especially useful because it is an allowed exam material, i.e. one can use it during the exam and quickly (control + f) look up relevant commands

Mostrar más Leer menos
Institución
Grado

Vista previa del contenido

% == 0 → no remainder of division x = “….”

// → highest possible value of div. (floor division) x.upper()

print(“…..” * x) → prints string is x = True x.replace(x, y) → x = what to replace, y = replace

X = (….) → Tuple, works same as list with what

x[…] → value of that position x.capitalize()

x.index(…) → position of that value x.count()

print( i in x) → prints True if possible x.index()

Adding to a list: x.find()

X = [….] x.format()

x.append(….) → with lists or strings Stride:

x = x + [….] my_string[ : : ] → start : end : incrementation

x.extend(….) my_string[ : : -1] → prints string in reverse

x += 1 Splitting:

x += x my_string.split( sep= …., maxsplit = ….)

sum += element sep = where should it be split up

sum = element += element maxsplit → 0 – indexing

Deleting an item: rsplit → starts from the back (right)

del x(….) \n → new line is started

del(x[….]) my_string.splitlines() → splits where is space

x.remove(…) Joining:

Copying a list: sep.join(iterable)

Y = x.copy(…) sep = what should it be separated with i.e. “ “

Y = x[ : ] Stripping:

Rounding: my_string.strip() → removes 1st and last character

round( x, y) → x = number to round, y = decimals or whatever is specified in ( )

format( x, .2f) → float with 2 decimals

format( x, “.2f”)

String methods

, Find substrings: f = float

my_string.find( substring, start, end) !s = string

→ substring = what should be found !r = string with “ “

Start, end → index positions Datetime f – string:

i.e. i.e. print(f” Today is {today: %B, %d, %y}”)

for i in x: in-line function like lambda:
try:
print(i.find(….)) num1 = …
except Value Error:
print(…) num2 = …

print(f”{num1} plus {num2} is {num1 + num2}”)
Print words on separate lines:
or with functions:
X=“…“
def main(num1, num2)
for word in x.split():
return num1 + num2
print(x)
print(f” … is {main(10, 20}”)
String Formatting:
Template method
Positional Formatting:
from string import Template
“text { } “.format(values to be included)
→ using $ as placeholder
print(“ text { } … .format(string1, string2 …)”)
(1) Create template
with index:
→ string1 = Template(“… $identifier .. “)
print(“ {index 1} … {index 2..}”.format(strings1 ..)”)
(2) Fill identifier variable
Placeholders with dictionary:
→ string1.substitute(identifier=”…..”)
dict1 = {key1: value1, key2: value2}
Use ${identifier} when elements are directly on
print(“{data[key1]} … “.format(data = dict1))
string1.safe_substitute(…) → only fills where
specify inside placeholder which format
possible, unfilled identifiers are unchanged
→ {index: format}
i=…
f – strings:
i.isnumeric() → if True then ..
f”literal string {expression}

print(f” …. {expression1} …)

here als {expression: format}

format → d = digit (integer)

Libro relacionado

Escuela, estudio y materia

Institución
Estudio
Grado

Información del documento

¿Un libro?
Subido en
25 de mayo de 2021
Número de páginas
6
Escrito en
2020/2021
Tipo
RESUMEN

Temas

$5.33
Accede al documento completo:

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Reseñas de compradores verificados

Se muestran los comentarios
4 año hace

4.0

1 reseñas

5
0
4
1
3
0
2
0
1
0
Reseñas confiables sobre Stuvia

Todas las reseñas las realizan usuarios reales de Stuvia después de compras verificadas.

Conoce al vendedor

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
mathiasm1 Universiteit van Amsterdam
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
52
Miembro desde
4 año
Número de seguidores
44
Documentos
10
Última venta
3 meses hace

3.9

11 reseñas

5
5
4
3
3
1
2
1
1
1

Documentos populares

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