Question
1. Design a Python program that continually prompts the user to enter positive numbers stopping when the user enters a non-positive number. The positive numbers
1. Design a Python program that continually prompts the user to enter positive numbers stopping when the user enters a non-positive number. The positive numbers should be stored in a Python list. After the list has been created, the program should once again continually prompt the user to enter a positive number stopping when the user enters a negative number or a number that is equal to or greater than the total number of entries in the previously created list. For each number (n) entered within that specified range, the program should use that number to identify nth largest number in the list. Additionally, your cannot use any global variables and the program must include the following:
A function that contains the code that creates the Python list. This function must explicitly return the list
A function that returns the nth
largest number in a Python list of numbers. The function must be provided the list as well as the value of n and return the value determinted to be the nth
largest number in the list.
2. Replace the code in the function that creates the Python list so that the numbers inserted into the list come from a text file instead of being entered as input from the user.
3. Using exception handling techniques (try-except) modify the code in the function from problem #1 so that it captures and handles errors related to non-numeric input and empty lists.
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