Python data input

Hello to all! Today we will continue to study Python, and get acquainted with such a thing as data entry. Agree – any program should process data that one way or another depends on the initial one – namely, the user will enter it. There are many examples of this. And the simplest is a calculator. So, the main task of the data entry function is to receive data from the user, after which these same data will be processed. The Python input () command is used to request data, but in practice, the code looks like this:

As you can see from the code – we request the value of a, after – the value of b. After that, the obtained values need to be processed. Let’s try to do this using the code below:

The specified code can be considered in this vein:
1. We request the value of the variable A: a = int (input (‘Enter the value A:’)) – where: a is the name of the variable, int is the type of the variable (we will talk about them a bit later), input is the data input request, represented by the text in brackets and quotation marks.
2. Similarly, we get the value of the variable b.
3. We derive the result of adding a + b. (an example of outputting the values of simple arithmetic operations is available here )

Interestingly, using the input command, you can get both digital and text values. For example, the code:

in more detail, it looks like this:
1. Set the variable name: text
2. Set the variable type – str (string)
3. We display a user input request: input (‘Enter a word:’))

It is important to know that the resulting text can be processed in a variety of ways. But more about that – in the next entry, which will be called that way: Python – string operations.

Thanks for your attention! Liked the record? Repost your page in social networks;) And of course – ask questions if you have any.