15. Data Input¶
Up until now our programs have worked with known values.
We will begin to obtain the values during the execution of the programs.
15.1. Data Input Conversion¶
The
input
function only returns strings.We use the
int()
andfloat()
functions to convert a value to an integer or a floating-point value respectively.
15.2. Common Error¶
Opening two parentheses and closing only one.
The same can happen to us with braces, brackets, quotes, among other characters.
{}
,[]
," "
whenever we open one we must remember to close it.The error will end with the following:
>>> unit_value = float(input("Value of a donut: ")
File <string>, line 1
unit_value = float(input("Value of a donut: ")
^
SyntaxError: '( was never closed
Whenever the line seems correct, check the immediately previous line.
You have attempted of activities on this page