Basic user input (text based)

Casi no hay programas sin ninguna entrada. La entrada puede venir en varias maneras, por ejemplo de una base de datos, de otra computadora, de tecleos y de movimientos del ratón o de Internet. Sin embargo, en la mayoría de los casos la entrada proviene del teclado. Para ello, Python proporciona la entrada de función (). La entrada tiene un parámetro opcional, que es la cadena de solicitud.

Si se llama a la función de entrada, el flujo del programa se detendrá hasta que el usuario haya dado una entrada y haya terminado la entrada con la tecla de retorno. El texto del parámetro opcional, es decir, el mensaje, se imprimirá en la pantalla.

La entrada del usuario se devolverá como una cadena sin ningún cambio. Si esta entrada sin procesar tiene que ser transformada en otro tipo de datos necesario para el algoritmo, podemos usar una función de casting o la función eval.

Ejemplo:

inputcod

inputpy

 

There are hardly any programs without any input. Input can come in various ways, for example from a database, another computer, mouse clicks and movements or from the internet. Yet, in most cases the input stems from the keyboard. For this purpose, Python provides the function input (). Input has an optional parameter, which is the prompt string.

If the input function is called, the program flow will be stopped until the user has given an input and has ended the input with the return key. The text of the optional parameter, i.e. The prompt, will be printed on the screen.

The input of the user will be returned as a string without any changes. If this raw input has to be transformed into another data type needed by the algorithm, we can use either a casting function or the eval function.

 

Fuente: python-course.eu

Para saber mas, visita el siguiente link: http://www.python-course.eu/python3_input.php

Leave a comment