Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using Python : Function get_integer(maximum,prompt) [2 points autograded] Use the Design Recipe to define a function get_integer(maximu m, prompt ) which consumes an int and

Using Python :

Function get_integer(maximum,prompt) [2 points autograded]

Use the Design Recipe to define a function get_integer(maximum,prompt) which consumes an int and a string and returns an integer. This function keeps asking the user to enter values using the prompt as the input message to the user until they enter one which can be interpreted as an integer between 0 and the argument to maximum. If they enter any character other than digits, or any integer outside the allowed range, keep asking until an acceptable value is obtained. If maximum <0, any (non-negative) integer should be accepted. Include a docstring!

Note: consider using the "isdigit()" string method.

For example:

Test
Input
Result
print(get_integer(100))
 

7w7 91 17

91

------------------------------------------------------------------------------------------------------

Function is_float(s) [2 points autograded]

Use the Design Recipe to define a function is_float(s) that consumes a string argument and returns True if the string can be turned into a float, and returns Falseotherwise. The string must contain only digits (at least one), (optionally) a single decimal, and (optionally) a leading - (if a negative value is desired). Otherwise, return False. Include a docstring!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

2nd Edition

0470624701, 978-0470624708

More Books

Students also viewed these Databases questions

Question

x-3+1, x23 Let f(x) = -*+3, * Answered: 1 week ago

Answered: 1 week ago

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago