human
Replace all â €˜ 0 â €™ with â €˜ 5 â €™ in an input Integer | .
returns the number to be added to the input to replace all zeroes with five.
amount to be added.
unit decimal place.
a number divisible by 10 , then this is a zero occurrence in the input.
move one decimal place.
Driver code"
How can the above be solved in Python?
assistant
#Here is code to replace all â €˜ 0 â €™ with â €˜ 5 â €™ in an input Integer and the other steps required.
 def replace0with5 ( 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 ( replace0with5 ( 1020 ) )