Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Python Shell File Edit Shel Debuc Jptions indows Help printTooLargest Please ent

ID: 3811702 • Letter: P

Question

Python Shell File Edit Shel Debuc Jptions indows Help printTooLargest Please enter a number: 5 Please enter a Muker: 10 Please enter a number: 3 Please enter a muhker: 12 Please enter a munker: -3 The largest is 12 The second largest is 10 print TooLargest Please enter a number: 5 Please enter a mutker: 25 Please enter a number: 5 Please enter a mumber: 20 Please enter a nurker: 25 Please enter a muutker: 0 The largest is 25 The second largest is 20 printTopLargest Please enter a numiter: 1 Please enter a munker: 0 Fever than too positive nukers vere entered. print TooLargest Please enter a numker: -2 Feoer than too positive numbers were entered. printTopLargest Please enter a nunker: ten That was not a valid muurber. Please trg again, Please enter a number: ten That was not a valid number. Please trg again. Please enter a munker: 10 Please enter a munker: 5 Please enter a number: 1 Please enter a number: -3 The largest is 10 The second largest is 5

Explanation / Answer

def printTwoLargest():
numSet=[]
num=1
while num>0:
num=eval(input('Please enter a number: '))
numSet.append(num)
if len(numSet)>=2:
print('The largest is ',max(numSet))
numSet.remove(max(numSet))
print('The second largest is ',max(numSet))
elif len(numSet)<2 and numSet[0]<1:
print('No positive numbers were entered.')