44EJERCIÓ
55"""
66#---STRING---
7- str = 'Hola Mundo'
8- print (f'String -> { str } ' )
7+ s1 = 'Hola Mundo'
8+ print (f'String -> { s1 } ' )
99
1010#---SUB-CADENA---
11- sub_str = str [5 :10 ]
12- print (f'Sub-Cadena -> { sub_str } ' )
11+ sub_s1 = s1 [5 :10 ]
12+ print (f'Sub-Cadena -> { sub_s1 } ' )
1313
1414#---LONGITUD---
15- length = len (str )
15+ length = len (s1 )
1616print (f'Longitud -> { length } ' )
1717
1818#---CONCATENACIÓN---
19- str1 = 'Hola'
20- str2 = 'Mundo'
21- result = str1 + str2
19+ s11 = 'Hola'
20+ s12 = 'Mundo'
21+ result = s11 + s12
2222print (f'Concatenación -> { result } ' )
2323
2424#---REPETICIÓN---
25- repeated = str * 3
25+ repeated = s1 * 3
2626print (f'Repetición -> { repeated } ' )
2727
2828#---MAYÚSCULAS Y MINÚSCULAS---
29- upper = str .upper ()
30- lower = str .lower ()
29+ upper = s1 .upper ()
30+ lower = s1 .lower ()
3131print (f'Mayúsculas -> { upper } ' )
3232print (f'Minúsculas -> { lower } ' )
3333
3434#---REEMPLAZO---
35- replaced = str .replace ("Mundo" , "Python" )
35+ replaced = s1 .replace ("Mundo" , "Python" )
3636print (f'Reemplazo -> { replaced } ' )
3737
3838#---DIVISION---
39- str_ = "Hola,Mundo,Python"
40- parts = str_ .split ("," )
39+ s1_ = "Hola,Mundo,Python"
40+ parts = s1_ .split ("," )
4141print (f'Division -> { parts } ' )
4242
4343#---UNION---
4747
4848#---INTERPOLACIÓN---
4949nombre = "Antonio"
50- str__ = "Hola {}" .format (nombre )
51- print (f'Interpolación -> { str__ } ' )
50+ s1__ = "Hola {}" .format (nombre )
51+ print (f'Interpolación -> { s1__ } ' )
5252
5353#---VERIFICACIÓN---
5454# --IGUALDAD--
55- str3 = "Hola Mundo"
56- is_equal = str == str3
55+ s3 = "Hola Mundo"
56+ is_equal = s1 == s3
5757print (f'Verificación-Igualdad (Hola Mundo == Hola Mundo) -> { is_equal } ' )
5858
5959# --EMPIEZA--
60- starts_with = str .startswith ("Hola" )
60+ starts_with = s1 .startswith ("Hola" )
6161print (f'Verificación-Empieza (Hola Mundo == Hola) -> { starts_with } ' )
6262
6363# --TERMINA--
64- ends_with = str .endswith ("Mundo" )
64+ ends_with = s1 .endswith ("Mundo" )
6565print (f'Verificación-Termina (Hola Mundo == Mundo) -> { ends_with } ' )
6666
6767# --CONTIENE--
68- contains = "Mundo" in str
68+ contains = "Mundo" in s1
6969print (f'Verificación-Contiene (Hola Mundo == Mundo) -> { contains } ' )
7070
7171
7272
7373"""
7474EXTRA
7575"""
76- #Pendiente
76+ def es_palíndromo (word ):
77+ word = word .lower ()
78+ return word == word [::- 1 ]
79+
80+ def son_anagramas (word1 , word2 ):
81+ word1 = word1 .lower ()
82+ word2 = word2 .lower ()
83+ return sorted (word1 ) == sorted (word2 )
84+
85+ def es_isograma (word ):
86+ word = word .lower ()
87+ return len (set (word )) == len (word )
88+
89+ def EXTRA (palabra1 : str , palabra2 : str ):
90+ #Palíndromo
91+ print (f'{ palabra1 } es un Palíndromo: { es_palíndromo (palabra1 )} ' )
92+ print (f'{ palabra2 } es un Palíndromo: { es_palíndromo (palabra2 )} ' )
93+
94+ #Anagrama
95+ print (f'{ palabra1 } es Anagrama de { palabra2 } : { son_anagramas (palabra1 , palabra2 )} ' )
96+
97+ #Isograma
98+ print (f'{ palabra1 } es un Isograma: { es_isograma (palabra1 )} ' )
99+ print (f'{ palabra2 } es un Isograma: { es_isograma (palabra2 )} ' )
100+
101+ EXTRA ('radar' , 'roma' )
0 commit comments