No program would be complete is it didn’t have a way to receive input from the user.
To receive input from the user in the Python programming language, we use the input() function.
The input() function is assigned to a value called a variable. Text is placed in between the brackets which serve as a prompt for the user.
The code above shows how to receive a value from the user. The value is then stored in a variable called name.
The value inside the name variable can then be printed out to the screen.
Concatenation is the joining of strings. In the Python programming language, the “+” is the concatenation operator.
In the example above, when you have a number, you must convert it to a string before you can concatenate it.
length = input("Please enter the length of the square: ") length = int(length) area = length * length print("The area of a square of length", length, "is", area)
Above is a simple program to find the area of a square. On line 2, the value received by the user is converted into an integer.
On line 4 when we print the output, we get the following output:
Note that the output has added spaces whereas, in the original program, we had none.
Overloading simply means that there are many ways to call a function.
Learn Python in One Week
If you want a quick and easy introduction to the Python programming language, you should check out my fifth book: Learn Python in One Week on the Amazon store.