Skip to content

Instantly share code, notes, and snippets.

@uroybd
Created June 29, 2020 11:46
Show Gist options
  • Save uroybd/476bdfb7911601aff30b4dd4bd932a3e to your computer and use it in GitHub Desktop.
Save uroybd/476bdfb7911601aff30b4dd4bd932a3e to your computer and use it in GitHub Desktop.
Largest and Smallest
import sys
largest_by_far = sys.float_info.min
smallest_by_far = sys.float_info.max
while True:
value = input("Enter Numbers: ")
if value == "done":
break
try:
fvalue = float(value)
largest_by_far = max(fvalue, largest_by_far)
smallest_by_far = min(fvalue, smallest_by_far)
except:
print("Invalid Input")
continue
print(f"Maximum is: {largest_by_far}")
print(f"Minimum is: {smallest_by_far}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment