Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The input parameter to L 0 6 0 4 b ( inString ) is expected to be a white - space delimited list of string
The input parameter to LbinString is expected to be a whitespace delimited list of string representations of decimal ints. For example, is a valid inString.
If inString contains a substring that is not white space or a valid decimal int, LbinStringno For example, Lb xF
no because xF is not a valid decimal int.
Otherwise, if inString does not contain a substring representing positive int, return no For example, Lbno
Otherwise, LbinString should return a string representing the sum of all positive ints in inString, mod For example,Lb would return because and Note that is the Python mod operator.
Download Lbtemplate.py Download Lbtemplate.py and modify it to implement the required logic.
Lbtemplate.py:
def LbinString:
# inString is a whitespace delimited list of string representations
# of decimal ints. For example, is a valid inString.
# If inString contains a whitespace delimited substring of symbols that
# is not a valid decimal int, LbinStringno For example,
# Lb xF no because xF is not a valid
# decimal int.
# Otherwise, if inString does not contain any representations of positive
# ints, return no
# Otherwise, LbinString returns the sum of all positive ints mod
# For example,Lb would return because
# Note that is the Python mod operator.
#
# Add the needed code.
#
return # returning a constant value will not work.
if namemain:
def testcaseFstring,expected,num,comment:
err
result Fstring
funcname strFsplit
funccall ffuncnamestring
if result expected: err
e expected
print ferrtest #numfunccall: expected e received
result
print ftest #num Explanation: comment
return num
F Lb
num
s
exp
num testcaseFnum,exp
s
exp No positive ints'
num testcaseFsnonum,exp
s
exp
num testcaseFsnum,exp
s x
exp x does not represent a decimal int"
num testcaseFsnum,exp
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started