Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python ask for real values until negative value diplay highest and lowest

print "Enter numbers, stops when negative value is entered:"
nums = []
while True: # infinite loop
    try: n = int(raw_input("Enter a number: ")) # raw_input returns a string, so convert to an integer
    except ValueError: 
        n = -1
        print "Not a number!"
    if n < 0: break # when n is negative, break out of the loop
    else: nums.append(n)
print "Maximum number: {}".format(max(nums))
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #real #values #negative #diplay #highest #lowest
ADD COMMENT
Topic
Name
4+6 =