Question: Write a python function divide(num1, num2) that takes in two positive integers and integer divides each of the corresponding digits to produce an answer. For

  1. Write a python function divide(num1, num2) that takes in two positive integers
  2. and integer divides each of the corresponding digits to produce an answer.
  3. For example, divide(356, 123) would equal 322 since 3//1 = 3 (hundreds place), 5//2 = 2 (tens place), and 6//3 = 2 (ones place).
  4. If any of the digits in the second number are 0, the answer should have a 0 in that place.
  5. Note that the integers may not necessarily have the same number of digits.
  6. You must use a try-except block for full credit.

def test_divide():

assert(divide(356, 123) == 322)

assert(divide(356, 1203) == 102)

assert(divide(6308, 5) == 1)

assert(divide(4, 835) == 0)

assert(divide(2468, 1357) == 2111)

print("done!")

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!