-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path03_strings.py
More file actions
63 lines (41 loc) · 1.34 KB
/
03_strings.py
File metadata and controls
63 lines (41 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Strings
my_string = 'My String'
my_other_string = "otro string"
my_strings = my_string, my_other_string
print(my_string + " " + my_other_string)
print(my_string + " " + my_other_string)
print(my_string + " y " + my_other_string)
my_new_line_string = 'Este es un \n salto de línea'
print(my_new_line_string)
my_tab_string = '\t Este es un texto con tabulación'
print(my_tab_string)
my_scape_string = '\\t Este es un texto \\n con escapado'
print(my_scape_string)
# Formateo
name, surname, age = 'Brian', 'Almada', 32
print('Mi nombre es {}, mi apellido es {} y mi edad es de {} años'.format(name, surname, age))
print('Mi nombre es %s, mi apellido es %s y mi edad es de %d años' %(name, surname, age))
print(f'Mi nombre es {name}, mi apellido es {surname} y mi edad es de {age} años')
# Desempaquetado de caracteres
language = 'Python'
a, b, c, d, e, f = language
print(a,f)
# División
language_slice = language[1:3]
print(language_slice)
language_slice = language[1:]
print(language_slice)
language_slice = language[-2]
print(language_slice)
# Reverse
language_reverse = language[::-1]
print(language_reverse)
# Funciones
print(language.capitalize())
print(language.upper())
print(language.count("t"))
print(language.isnumeric())
print("1".isnumeric())
print(language.lower())
print(language.upper().isupper())
print(language.startswith("py"))