I can not find a mistake! Help me please.
Code:
a = input('делимое') b = input('делитель') print('Ответ: {:.2%}'.format(a/b)) I can not find a mistake! Help me please.
Code:
a = input('делимое') b = input('делитель') print('Ответ: {:.2%}'.format(a/b)) It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:
The input() function returns strings, not numbers. Before dividing, you need to convert them into numbers, like this:
a = int(input('делимое')) b = int(input('делитель')) ... if you need integers, or
a = float(input('делимое')) b = float(input('делитель')) ... if floating point numbers are needed.
The next time you ask a question in error, indicate the error in the text of the question. In this case, it is not critical, because The code is small, but generally it is always better to specify.
input() in Python2 is more intelligent than in Python3. - insolorfloat(raw_input()) explicitly). Maybe OP does not know that 1/2==0 in Python 2 or how the % format works. Share your mind reading equipment;) - jfsprint as in Python3, although this still doesn’t mean anything. Assuming that this is Python3, then the error is that the input data is not converted to numbers. Although it may still be Python2, and the author really did not expect to see the answer as a percentage. - insolorSource: https://ru.stackoverflow.com/questions/530251/
All Articles