
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
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).](https://content.bartleby.com/qna-images/question/6128a30d-be3c-4f5f-a17a-54eaa3ca9284/d2e64ea7-ad55-49aa-98e3-6bc275949c0d/72d2scc_thumbnail.png)
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

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 2 steps

Knowledge Booster
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
- Add a function to get the CPI values from the user and validate that they are greater than 0. 1. Declare and implement a void function called getCPIValues that takes two float reference parameters for the old_cpi and new_cpi. 2. Move the code that reads in the old_cpi and new_cpi into this function. 3. Add a do-while loop that validates the input, making sure that the old_cpi and new_cpi are valid values. + if there is an input error, print "Error: CPI values must be greater than 0." and try to get data again. 4. Replace the code that was moved with a call to this new function. - Add an array to accumulate the computed inflation rates 1. Declare a constant called MAX_RATES and set it to 20. 2. Declare an array of double values having size MAX_RATES that will be used to accumulate the computed inflation rates. 3. Add code to main that inserts the computed inflation rate into the next position in the array. 4. Be careful to make sure the program does not overflow the array. - Add a…arrow_forwardWrite a function that returns the greatest common divisor of 2 integers.arrow_forwardRefactor the following code using the concept of functions. a = 2 b = 3 C= 4 d = 5 a = 2 b = 3 C= 4 d = 5arrow_forward
- //Write a function that loops through and console.log's the numbers from 1 to 100, except multiples of three, log (without quotes) "VERY GOOD" instead of the number, for the multiples of five, log (without quotes) "SUPER AWESOME". For numbers which are multiples of both three and five, log (without quotes) "VERY GOOD SUPER AWESOME" Console log out: 12VERY GOOD4SUPER AWESOMEVERY GOOD78VERY GOODSUPER AWESOME11VERY GOOD1314VERY GOOD SUPER AWESOME1617VERY GOOD19SUPER AWESOMEVERY GOOD2223VERY GOODSUPER AWESOME26VERY GOOD2829VERY GOOD SUPER AWESOMEarrow_forwardWrite a function that takes the current date and corrects the number of days, if it's wrong. The function must return true if the date passed to it is a valid date and false, if not. The main function uses the returned value to either print "Date validated", if a valid date was entered or "Invalid date entered. Changed to ", followed by the modified date.arrow_forward4.Rohan bought a gallon of milk with an original price of $4.25; today he gets a 15% discount before a 5% tax; display the final price of the milk.5.This function is named compound_interest, takes these arguments p r n t; compute and return a for displaya = p (1 + r/n) nt6.This function is named annuities, takes these arguments r i n; compute and return s for displays = r ((1 + i)^(n + 1))/i - rarrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education