Created
June 3, 2021 21:58
-
-
Save alejandrobernardis/fea91fea578003b27ecd4e1902ebfe01 to your computer and use it in GitHub Desktop.
Class -- Pedro 2021-06-03
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Author: Alejandro M. BERNARDIS | |
# Email alejandro.bernardis at gmail dot com | |
# Created: 2021-06-03 | |
# le asigno el valor en formato string a la variable mensaje. | |
mensaje = 'A mi me encanta programar en python.' | |
# imprimo el total de caracteres | |
print('Cuántos caracteres tengo?:', len(mensaje)) | |
# imprimo el total de caracteres sin espacios en blanco | |
print('Cuántos caracteres tengo?:', len(mensaje.replace(' ', ''))) | |
# concateno dos textos | |
nuevo_mensaje = mensaje + ' Espero ser bueno.' | |
# imprimo los valores | |
print('mensaje ->', mensaje) | |
print('nuevo mensaje ->', nuevo_mensaje) | |
# leer una posición específica de la cadena de texto | |
print('nuevo_mensaje[0] ->', nuevo_mensaje[0]) | |
print('nuevo_mensaje[6] ->', nuevo_mensaje[6]) | |
print('nuevo_mensaje[15] ->', nuevo_mensaje[15]) | |
print('nuevo_mensaje[16] ->', nuevo_mensaje[16]) | |
print('nuevo_mensaje[17] ->', nuevo_mensaje[17]) | |
# A| |m|i| |m|e| |e|... | |
# 0|1|2|3|4|5|6|7|8|... | |
print('nuevo_mensaje[5] ->', nuevo_mensaje[5]) | |
# Pedro, cada día aprende un poco más de python. | |
# ^ ^ ^ ^^^ ^ ^ ^ | |
pedro = 'Pedro, cada día aprende un poco más de python.' | |
print('o =', pedro[4]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment