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

(PYTHON) In completing this task, you will need to use the following constructs:

ID: 3672102 • Letter: #

Question

(PYTHON)

In completing this task, you will need to use the following constructs:
1. IF / ELSE statements

2. WHILE loops
Other than the items listed above, the TA should not need to cover any additional programming concepts.
For this task, you will prompt the user for a series of numbers and output the largest value entered. Again, continue to prompt the user until a negative number is entered. Here's the sample output (bold underline indicates user input):

Enter number 1: 3

Enter number 2: 7

Enter number 3: 4

Enter number 4: 1

Enter number 5: -1


The largest number entered is: 7

Explanation / Answer

def largestNumber():
   a = 0
   largest = -1
   count = 0
   while a >= 0 :
       print "Enter number ", (count+1)
       a = input()
       if a > largest :
           largest = a
       count += 1
   print "The largest number entered is ", largest

largestNumber()