Question: NO STRINGS, LOOPS OR RECUURSION!!!! PYTHON Implement the function setKthDigit(n, k, d) that takes three integers n, k, d where n is a possibly-negative integer,
NO STRINGS, LOOPS OR RECUURSION!!!!
PYTHON
Implement the function setKthDigit(n, k, d) that takes three integers n, k, d where n is a possibly-negative integer, k is a non-negative integer, and d is a non-negative single digit integer (between 0 and 9 inclusive). This function returns the number n with the k th digit replaced with d. Counting starts at 0 and goes right-to-left, so the 0 th digit is the rightmost digit. Note that if k is larger than the number of digits in n, the function must return False and print out the message Index out of range. For example (below, the equality symbol == is used to denote the resul of calling the function with the given arguments): setKthDigit (468 , 0 , 1) == 461 setKthDigit (468 , 1 , 1) == 418 setKthDigit (468 , 2 , 1) == 168 setKthDigit (468 , 3 , 1) == 1468 setKthDigit (468 , 1 , 0) == 408 setKthDigit ( -809 , 1 , 7) == -879 setKthDigit (0 , 2, 7) == False
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
