-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassign1annot.py
More file actions
28 lines (22 loc) · 1.04 KB
/
assign1annot.py
File metadata and controls
28 lines (22 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
largest = None # set variable value
smallest = None # set variable value
while True: # begin while loop
value = input('Enter a number: ')
if value == 'done':
break
try:
intvalue = int(value) # confirm value is an int / converts to an int
except:
print('Invalid input')
continue # keeps prog running in case of invalid input
if smallest is None:
smallest = intvalue # sets the smallest value to input if None (our initial value)
elif intvalue < smallest: # compares if less than current smallest value
smallest = intvalue # if returns true , then sets that as the current
# current smallest value
if largest is None: # same as above but in reverse direction
largest = intvalue # to set largest values inputted
elif intvalue > largest:
largest = intvalue
print('Maximum is', largest) # returns to screen max and min values
print('Minimum is', smallest)