about | help | code help+videos | done | prefs |
div
The number which we divide is called the dividend. The number by which we divide is called the divisor. The result obtained is called the quotient. The number left over is called the remainder. Given a dividend and a divisor - both positive integers - return a string of the quotient and the remainder in the format #r# (if the remainder is 0, omit the r#). For example, 13 divided by 5 should return the string 2r3 and 20 divided by 5 should return only the string 4. NOTE: Codingbat uses Python 2.6 in which / represents an integer divide. Thus in Python 2.6, 17/5 is equal to the 3. In Python 3.x, 17/5 is equal to 3.4. In Python 2.6, to get a float as an answer for / you must convert either the dividend or the divisor to a float - e.g. float(17)/5 is equal to 3.4. div(17, 5) → '3r2' div(15, 5) → '3' div(27, 6) → '4r3' ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 100
Copyright Nick Parlante 2017 - privacy