Search
 
SCRIPT & CODE EXAMPLE
 

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))
Comment

PREVIOUS NEXT
Code Example
Python :: how to save multiple choices in django site:stackoverflow.com 
Python :: create empty polygon python 
Python :: sumif in python on a column and create new column 
Python :: python add new line from textarea 
Python :: how to import pil in spyder 
Python :: how to get a mouse press not hold in pygame 
Python :: Mat.at(row,col) Opencv 
Python :: spyder - identation 
Python :: hpw to create related model in django rest framework logic 
Python :: django filter word count greater than 
Python :: root = tk.Tk() my_gui = App1(root) 
Python :: creating a frequency table | generating a frequency table 
Python :: inspect last 5 rows of dataframe 
Python :: boolean indexing datetime object | converting string to datetime object 
Python :: fibonacci series python program 
Python :: convert python code to java using jython 
Python :: add vertical line to horizontal graph 
Python :: boto3 cross region 
Python :: mongoengine ObjectIdField 
Python :: fastapi authentication 
Python :: mechanize python #2 
Python :: how to add an symbol to a certain part of a list python 
Python :: return Response converting to string drf 
Python :: get inverse of bool value python 
Python :: # to check if the list is empty use len(l) or not 
Python :: turn of legend pairplot 
Python :: FizzBuzz in Python Using Lambda 
Python :: logging errors into emails 
Python :: tuple with mixed data types 
Python :: python print numbers with commas 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =