The example above is inconvenient because the source data for the program is specified in the program text, and in order to use the program for another triangle, it is necessary to correct the program text. This is inconvenient; it is better that the program text does not change, and the program asks the user for the data necessary to solve the problem, that is, it asks for the values of two initial variables a and b. To do this, we will use the function input(), which reads a line from the keyboard and returns the value of the read line, which we will immediately assign to the variables a and b:
a = input()
b = input()
True, the function input returns a text string, but we need to make sure that the variables have integer values. Therefore, immediately after reading, we will perform a type conversion using the function int, and write the new values to the variables a and b.
a = int(a)
b = int(b)
You can combine string reading and type conversion by calling the function int on the value that the function returns input:
a = int(input())
b = int(input())
Next in the program we will calculate the value of the variable c and display the result on the screen.
Now we can reuse it to solve various problems without changing the source code of the program. To do this, you need to start the program and after starting the program, enter two numbers from the keyboard, pressing the key after each number Enter. Then the program will print the result itself.