Answer to Question #309026 in Python for None

Question #309026

Your given a string of numbers A, the task is to find the max value from the string A ; you can add a '+' or '*' sign between two numbers. For Ex S=452 as 4*5*2 = 40 and 4*5+2=22 So 40 is maximum.

Write a python module Maxvalue.py for solving the above task. You need to import this module in main program. In main program define a function F-M(n) which takes a string and returns maximum value or error message as shown in example by calling the appropriate function implemented in Maxvalue,py module. Also handle the exceptions and display the exception message in the form of string. F-M(n) function must be generalized one.


1
Expert's answer
2022-03-10T07:16:58-0500
Num = str(input("Enter a number: "))


MaxVal=1
for r in range(0,len(Num)):
    if(Num[r]!="0" and Num[r]!="1"):
        MaxVal = MaxVal*int(Num[r])
for r in range(0,len(Num)):
    if(Num[r]=="1"):
        MaxVal = MaxVal+int(Num[r])
print("Max. Value = ",MaxVal)

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