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
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
Step by step
Solved in 4 steps with 2 images