Fundamentos de Programación y Python
¿Por qué aprender Python?
Introducción a Python
Conceptos Básicos de Programación
Práctica: Te doy la bienvenida a los ejercicios interactivos
Manipulación de Cadenas de Texto en Python
Enteros, Flotantes y Booleanos
Todo lo que Debes Saber sobre print en Python
Operaciones Matemáticas en Python
Operaciones de Entrada/Salida en Consola
Colección y Procesamiento de Datos en Python
Listas
Método slice
Listas de más dimensiones y Tuplas
Aplicación de Matrices
Diccionarios
Comprehension Lists en Python (CLASE NUEVA)
Control de Flujo en Python
Estructuras condicionales
Bucles y Control de Iteraciones
Generadores e Iteradores
Funciones y Manejo de Excepciones en Python
Uso de Funciones en Python
Funciones Lambda y Programación Funcional en Python
¿Cómo realizar una función recursiva en Python?
Manejo de Excepciones y Uso de Pass (CLASE NUEVA)
Programación Orientada a Objetos en Python
Fundamentos de Programación Orientada a Objetos en Python
Ejercicio Biblioteca con POO
Herencia en POO con Python
Objetos heredados
Los 4 pilares de la programacion orientada a objetos
Uso de super() en Python (CLASE NUEVA)
Superando los Fundamentos de Programación Orientada a Objetos en Python
Lectura y escritura de archivos
Manejo de Archivos .TXT (CLASE NUEVA)
Manejo de Archivos CSV (CLASE NUEVA)
Manejo de Archivos JSON (CLASE NUEVA)
Biblioteca estándar de Python
Biblioteca estándar en Python (CLASE NUEVA)
Librería Os, Math y Random (CLASE NUEVA)
Librería Statistics y Análisis Estadístico (CLASE NUEVA)
Proyecto final: Guerra naval
Conceptos avanzados de Python
Recapitulación de lo aprendido hasta ahora
Escribir código Pythonico y profesional
Comentarios y Docstrings en Python
Scope y closures: variables locales y globales
Anotaciones de tipo
Validación de tipos en métodos
Librería Collections y Enumeraciones
Decoradores
Decoradores en Python
Decoradores anidados y con parámetros
Uso de Decoradores en clases y métodos
Métodos y estructura de clases en Python
Métodos mágicos
Sobrecarga de operadores
Implementación de `if __name__ == "__main__":`
Metaprogramación en Python
Uso de *args y **kwargs
Métodos privados y protegidos
Gestión avanzada de propiedades
Métodos estáticos y de clase avanzados
Programación concurrente y asíncrona
Introducción a la concurrencia y paralelismo
Threading y multiprocessing en Python
Asincronismo con asyncio
Asincronismo y concurrencia
Creación de módulos y paquetes
Creación de módulos en Python
Gestión de paquetes
Publicación de paquetes en PyPI
Proyecto final
Implementación de un sistema completo
Implementación de un Sistema Completo
You don't have access to this class
Keep learning! Join and start boosting your career
In Python, when working with projects that require user interaction, it is common to request data such as email or password to perform specific actions. This same approach is useful to understand the input
function.
To receive user information from the console, we create a variable and assign the result of the input
function. For example, to ask for the user's name:
name = input("Enter your name: ") print(name)
When this code is executed, a section for entering information is enabled. We enter a name, press Enter and the value stored in the variable name
is printed.
print
function?If we delete print
and execute the code, the name entered will not be displayed in the console:
name = input("Enter your name: ")
To see the result, it is essential to use print.
We can request the user's age by creating an age
variable and using input
, then print both values:
name = input("Enter your name: ") age = input("Enter your age: ") print(name) print(age)
When executed, we enter the name and age, and both values are displayed on the screen.
The result of input
is always a string, even if we enter a number. We can check the data type using type
:
name = input("Enter your name: ") age = input("Enter your age: ") print(type(name)) print(type(age(age)))
When executed, it will show that both values are of type str
.
If we want the age to be an integer instead of a string, we use casting:
age = int(input("Enter your age: "))
We run and verify that age
is now an integer. We can also convert to other data types, such as float:
age = float(input("Enter your age: "))
If the code expects an integer, but we enter a string, a ValueError
occurs. It is important to handle the data type correctly to avoid errors:
Contributions 34
Questions 6
Want to see more contributions, questions and answers from the community?