Answered step by step
Verified Expert Solution
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
- 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 example, divide(356, 123) would equal 322 since 3//1 = 3 (hundreds place), 5//2 = 2 (tens place), and 6//3 = 2 (ones place).
- If any of the digits in the second number are 0, the answer should have a 0 in that place.
- Note that the integers may not necessarily have the same number of digits.
- 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started