Answered step by step
Verified Expert Solution
Question
1 Approved Answer
6.5.6 Enter a Positive Number 1 In this exercise, you get to put together a bunch of the knowledge you've acquired in this module! Write
6.5.6 Enter a Positive Number 1 In this exercise, you get to put together a bunch of the knowledge you've acquired in this module! Write a function called retrieve_positive_number that repeatedly asks the user for a positive number. If the user enters a negative number or zero, the function should tell them and reprompt. If the user enters something that isn't a number, the function should also tell them and reprompt. When the user finally enters a positive number, the function should return this number. Call this function to test it! You will need: - A function definition, with no parameters. - A try and except block. - A while loop. - A return statement. - An if statement. Hint: The return keyword is even more powerful than break. If you are inside of a loop, and that loop is inside of a function, break just breaks out of the loop. return, on the other hand, breaks out of the entire function (and possibly also returns a value)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started