Answer to Question #293983 in Python for Michael

Question #293983

Write a python function Sum(ele) which takes a comma-separated string of numbers and returns the reverse of the sum of the smallest and largest numbers in the given list as shown in the example. For example, for the list 10, 23, 14, 25, the sum of smallest and largest numbers is 35. And the reverse of 35 is 53.

NOTE:

  1. Write a separate recursive function reverse_num(num)to compute the reverse of a number and call this function inside the Sum(ele).
  2. Do not use the input() function for taking input from the keyboard. Specify the input in fixed form but function must be generalized that can work with values.




1
Expert's answer
2022-02-05T02:04:13-0500
def Sum(ele):
    list_ele = list(map(int,ele.split(',')))
    Max = max(list_ele)
    Min = min(list_ele)
    rev = 0
    temp = Max
    while temp != 0:
        rev = rev*10 + temp%10;
        temp //= 10
    return {Max + Min,rev}
    
ele = input()
sum_of_ele, reverse = Sum(ele)
print(sum_of_ele,reverse)

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