Write the following functions and their docstrings: • between (num1, num2, num3) takes 3 integer arguments and returns True if num2 is between num1 and num3. It is not between them if it is equal to either of the other two. For example, given the inputs 5, 3 and 0, the value returned should be True. Given the inputs -2, 2 and 2, False should be returned. Note that there is no restriction that num1 must be less than num3. • majorityEven (num_list) returns True if more than half of the integers in the num_list are di- visible by 2, with no remainder, otherwise it returns False. The list can be of any size. Recall that zero is divisible by 2 with no remainder. For example, the function should return False for the list [1,2,3,6] (as only two of the four numbers are divisible by 2) and True for the list [0,1,-4] (as two of the three numbers are divisible by 2).

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter6: Modularity Using Functions
Section6.2: Returning A Single Value
Problem 2E: (Practice) For the following function headers, determine the number, type, and order (sequence) of...
icon
Related questions
Question
(a) Write the following functions and their docstrings:
• between (num1, num2, num3) takes 3 integer arguments and returns True if num2 is between num1
and num3. It is not between them if it is equal to either of the other two. For example, given the
inputs 5, 3 and 0, the value returned should be True. Given the inputs -2, 2 and 2, False should be
returned. Note that there is no restriction that num1 must be less than num3.
• majorityEven (num_list) returns True if more than half of the integers in the num_list are di-
visible by 2, with no remainder, otherwise it returns False. The list can be of any size. Recall that
zero is divisible by 2 with no remainder. For example, the function should return False for the list
[1,2,3,6] (as only two of the four numbers are divisible by 2) and True for the list [0,1,-4] (as
two of the three numbers are divisible by 2).
(b) Generate at least six test cases for each function you wrote in part (a). You may use white-box and/or
black-box test case generation. Carefully and strategically select your white-box test cases. As you
choose your cases, try to think about all the different paths of execution through your code and identify
cases that cause the execution of each of those paths at least once.
(c) Implement a test driver which thoroughly tests both functions using the tests identified in part (b).
You can use either plain if-statements (as demonstrated in readings 15.2.4) or a list-of-dictionaries to
implement your test driver (as demonstrated in class during chapter 15 exercise 3).
Transcribed Image Text:(a) Write the following functions and their docstrings: • between (num1, num2, num3) takes 3 integer arguments and returns True if num2 is between num1 and num3. It is not between them if it is equal to either of the other two. For example, given the inputs 5, 3 and 0, the value returned should be True. Given the inputs -2, 2 and 2, False should be returned. Note that there is no restriction that num1 must be less than num3. • majorityEven (num_list) returns True if more than half of the integers in the num_list are di- visible by 2, with no remainder, otherwise it returns False. The list can be of any size. Recall that zero is divisible by 2 with no remainder. For example, the function should return False for the list [1,2,3,6] (as only two of the four numbers are divisible by 2) and True for the list [0,1,-4] (as two of the three numbers are divisible by 2). (b) Generate at least six test cases for each function you wrote in part (a). You may use white-box and/or black-box test case generation. Carefully and strategically select your white-box test cases. As you choose your cases, try to think about all the different paths of execution through your code and identify cases that cause the execution of each of those paths at least once. (c) Implement a test driver which thoroughly tests both functions using the tests identified in part (b). You can use either plain if-statements (as demonstrated in readings 15.2.4) or a list-of-dictionaries to implement your test driver (as demonstrated in class during chapter 15 exercise 3).
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning