There is a learning task: "The price of the goods is denominated in rubles with the accuracy of kopecks, that is, a real number with two digits after the decimal point. Write the value of the goods in the form of an integer number of rubles and an integer number of kopecks in two integer variables and output them on the screen. tasks cannot use conditional instructions and cycles. "

The task contains tests:
Test 1
Input data:

10.35 

The output of the program:

 10 35 

Test 2
Input data:

 1.99 

The output of the program:

 1 99 

Test 3
Input data:

 3.50 

The output of the program:

 3 50 

The following solution passes the above tests, and also: 0.01, 0.10, 40.80, 40.30, 1.01, 1.10

However, the training system produces: Test 5 Wrong answer.

Please help with the test version, which the program will not work. I can not think that I do not take into account.

 p = float(input()) r = int(p) print(r, end=' ') p *= 10 kk = p % 10 p *= 10 kd = p % 10 print(int(kk), int(kd), sep='') 
  • Comments are not intended for extended discussion; conversation moved to chat . - Qwertiy
  • Answers - in the answers, not the question. - Qwertiy

2 answers 2

slemik: The final code that helped pass the task:

 rubles = float(input()) kopeks = round(rubles * 100) print(*divmod(kopeks, 100)) 

    To support arbitrarily large input (for hyperinflationary times, so as not to be limited to the range that the float can accurately represent), you can immediately convert the string to integers:

     print(*map(int, input().partition('.')[::2])) # 1.50 -> 1 50