Question
In climb.py, write a function valid_range(a,b) returning True or False to check whether a and b are specifying a valid index range of the staircase.
In climb.py, write a function valid_range(a,b) returning True or False to check whether a and b are specifying a validindexrange of the staircase. We also specify that a =>
0\le a\le b
Once you have implemented this function, please come up with six (6) test cases of valid_range(a,b) and write them in climb.py.
A sample test case in your climb.py will look something like the following:
print("Expect: True, got: ",valid_range(some_number, some_other_number))
print("Expect: False, got: ",valid_range(some_number, some_other_number))
Three of your tests cases should return True and the rest should return False.
Your test cases should be different than those provided in the auto-grader. There will not be hidden test cases for this portion or this PA overall.
Note that both the implementation of function valid_range and your test cases will be graded.
def climb(a,b)
Sol5:
Here's one possible implementation of the valid_range function and some test cases:
def valid_range(a, b):
return 0 =>=>
# Test cases
print("Expect: True, got:", valid_range(0, 0))
print("Expect: True, got:", valid_range(10, 20))
print("Expect: True, got:", valid_range(44, 44))
print("Expect: False, got:", valid_range(-1, 5))
print("Expect: False, got:", valid_range(30, 20))
print("Expect: False, got:", valid_range(5, 50))
The valid_range function takes two parameters a and b and returns True if the range specified by a and b is valid according to the constraints specified in the problem statement, and False otherwise.
The test cases include three valid range cases and three invalid range cases. The first three test cases should return True since they specify valid ranges that meet the constraints. The last three test cases should return False since they specify invalid ranges that violate the constraints.
In climb.py, write a function valid_range(a,b) returning True or False to check whether a and b are specifying a validindexrange of the staircase. We also specify that a =>
0\le a\le b
Once you have implemented this function, please come up with six (6) test cases of valid_range(a,b) and write them in climb.py.
A sample test case in your climb.py will look something like the following:
print("Expect: True, got: ",valid_range(some_number, some_other_number))
print("Expect: False, got: ",valid_range(some_number, some_other_number))
Three of your tests cases should return True and the rest should return False.
Your test cases should be different than those provided in the auto-grader. There will not be hidden test cases for this portion or this PA overall.
Note that both the implementation of function valid_range and your test cases will be graded.
def climb(a,b)
Sol5:
Here's one possible implementation of the valid_range function and some test cases:
def valid_range(a, b):
return 0 =>=>
# Test cases
print("Expect: True, got:", valid_range(0, 0))
print("Expect: True, got:", valid_range(10, 20))
print("Expect: True, got:", valid_range(44, 44))
print("Expect: False, got:", valid_range(-1, 5))
print("Expect: False, got:", valid_range(30, 20))
print("Expect: False, got:", valid_range(5, 50))
The valid_range function takes two parameters a and b and returns True if the range specified by a and b is valid according to the constraints specified in the problem statement, and False otherwise.
The test cases include three valid range cases and three invalid range cases. The first three test cases should return True since they specify valid ranges that meet the constraints. The last three test cases should return False since they specify invalid ranges that violate the constraints.
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