Answer to Question #218182 in Python for Krish

Question #218182

Write a program to replace elements with zeros


1
Expert's answer
2021-07-21T01:55:12-0400
def replace(number):
    number += calculateAddedValue(number)
    return number
     

def calculateAddedValue(number):
     
    
    result = 0
     
    
    decimalPlace = 1
 
    if (number != 0):
        result += (5 * decimalPlace)
         
    while (number > 0):
        if (number % 10 != 0):
            
            result += (5 * decimalPlace)
             
                number //= 10
        decimalPlace *= 10
     
    return result
     

print(replace(1020))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS