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

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter6: User-defined Functions
Section: Chapter Questions
Problem 1TF: Mark the following statements as true or false: a. To use a predefined function in a program, you...
icon
Related questions
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
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Types of Function
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++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,