Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Security

Authors: Alfred Basta, Melissa Zgola

1st Edition

1435453905, 978-1435453906

More Books

Students also viewed these Databases questions

Question

Explain the function and purpose of the Job Level Table.

Answered: 1 week ago