Question
using python !! Write a function printTwoLargest() that inputs an arbitrary number of positive numbers from the user. The input of numbers stops when the
using python !!
Write a function printTwoLargest() that inputs an arbitrary number of positive numbers from the user. The input of numbers stops when the first negative or zero value is entered by the user. The function then prints the two largest values entered by the user. If no positive numbers are entered a message to that effect is printed instead of printing any numbers. If only one number is inputted, only the largest is printed out (see 2nd example below). Sample output:
>>> printTwoLargest()
Please enter a number: 12
Please enter a number: 99.9
Please enter a number: 4.5
Please enter a number: 77
Please enter a number: 0
The largest is 99.9
The second largest is 77
>>> printTwoLargest()
Please enter a number: 23.2
Please enter a number: -99
The largest is 23.2
>>> printTwoLargest()
Please enter a number: -9
No positive numbers were entered
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