Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

bartleby

Concept explainers

Question

Python question, please us a docstring and have comments throughout code

  • Write a function getInteger() that takes two integers num1 and num2 as parameters. If num1 > num2, then the function prints an error message and returns 0. If num1 is equal to num2, the function returns the common value. For cases where num1 < num2, the function prompts the user to enter an integer greater than or equal to num1 and less than or equal to num2 and returns the first valid integer that the user enters. If the user enters something that is not an integer value, the programs should display an error message and re-prompt the user to enter a valid integer Below are some sample executions of the function. Use the while and if-elif statements and a try/except in the solution. Don’t forget to include the docstring and comments. Copy and paste or screen shot the code and the thirteen test cases shown below in your submission. .

>>> getInteger(5,4)

5 and 4 are not valid parameters

0

>>> getInteger(10,10)

10

>>> getInteger(1,10)

Enter an integer between 1 and 10 : five

Please enter a whole number using digits.

Enter an integer between 1 and 10 : 5.5

Please enter a whole number using digits.

Enter an integer between 1 and 10 : [5]

Please enter a whole number using digits.

Enter an integer between 1 and 10 : 0

This is not in the correct range

Enter an integer between 1 and 10 : 11

This is not in the correct range

Enter an integer between 1 and 10 : 5

5

>>> getInteger(-5,5)

Enter an integer between -5 and 5 : negative 3

Please enter a whole number using digits.

Enter an integer between -5 and 5 : -3.5

Please enter a whole number using digits.

Enter an integer between -5 and 5 : -6

This is not in the correct range

Enter an integer between -5 and 5 : 6

This is not in the correct range

Enter an integer between -5 and 5 : -3

-3

Expert Solution
Check Mark
Knowledge Booster
Background pattern image
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
    Text book image
    Database System Concepts
    Computer Science
    ISBN:9780078022159
    Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
    Publisher:McGraw-Hill Education
    Text book image
    Starting Out with Python (4th Edition)
    Computer Science
    ISBN:9780134444321
    Author:Tony Gaddis
    Publisher:PEARSON
    Text book image
    Digital Fundamentals (11th Edition)
    Computer Science
    ISBN:9780132737968
    Author:Thomas L. Floyd
    Publisher:PEARSON
    Text book image
    C How to Program (8th Edition)
    Computer Science
    ISBN:9780133976892
    Author:Paul J. Deitel, Harvey Deitel
    Publisher:PEARSON
    Text book image
    Database Systems: Design, Implementation, & Manag...
    Computer Science
    ISBN:9781337627900
    Author:Carlos Coronel, Steven Morris
    Publisher:Cengage Learning
    Text book image
    Programmable Logic Controllers
    Computer Science
    ISBN:9780073373843
    Author:Frank D. Petruzella
    Publisher:McGraw-Hill Education