Answer to Question #282028 in Python for saikalyan reddy

Question #282028

input : the first line of input contains seperated integers


Outpt : The output should be a single line containing space-seperated integers with odd-digit for each number


if input 1 is :- 21 503 256 550 86 979 281


if output 1 is :- 12 503 562 550 86 979 128


if input 2 is :- 2001 463 6219 669 473 1006 77734 110 20511


if output 2 is :- 1002 346 1962 966 734 1006 77734 110 51120


1
Expert's answer
2021-12-22T14:24:17-0500
# Python3 implementation of the approach


# function to return the count of digit of n
def numberofDigits(n):
	cnt = 0
	while n > 0:
		cnt += 1
		n //= 10
	return cnt
	
# function to print the left shift numbers
def cal(num):
	digit = numberofDigits(num)
	powTen = pow(10, digit - 1)
	
	for i in range(digit - 1):
		
		firstDigit = num // powTen
		
		# formula to calculate left shift
		# from previous number
		left = (num * 10 + firstDigit -
			(firstDigit * powTen * 10))
		print(left, end = " ")
		
		# Update the original number
		num = left
		
# Driver code
num = 1445
cal(num)

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