![]() ![]() |
Conceptual Review (page 13 of 55) |
The input() function pauses the execution of your program and waits for a user to enter something (>? in the Terminal or Console). All user inputs are stored as strings by default, so we must cast the inputs to numerical data types if we want them treated as numbers.
In the above snippet of code, notice how the "+" operator means different things depending on the type of object. In the first statement, the "+" is concatenating strings together. In the last statement, the "+" is performing an addition between two integers. Therefore, it is important that we know what class or data type we are working with to avoid Traceback or logic errors in our scripts.