Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

using Python: Write a function named safe input(prompt,type) that works likethe Python input function, except that it only accepts thespecified type of input. The function

using Python:

Write a function named safe input(prompt,type) that works likethe Python input function, except that it only accepts thespecified type of input. The function takes two arguments:
r prompt: str
r type: int, float, str
The function will keep prompting for input until correct input ofthe specified type is entered.
The function returns the input. If the input was specified to be anumber ( float or int), the value returned will be of the correcttype; that is, the function will perform the conversion.
The default for a prompt is the empty string. The default for thetype is string.

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

Step: 3

blur-text-image

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

Computer Performance Engineering 10th European Workshop Epew 2013 Venice Italy September 17 2013 Proceedings

Authors: Maria Simonetta Balsamo ,William Knottenbelt ,Andrea Marin

2013 Edition

3642407242, 978-3642407246

More Books

Students also viewed these Programming questions

Question

Implement the method keys () for HashST.

Answered: 1 week ago

Question

How are interest rates used to allocate capital among firms?

Answered: 1 week ago