-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssigment_5.2_Coursera_Python.py
More file actions
67 lines (44 loc) · 1.02 KB
/
Copy pathAssigment_5.2_Coursera_Python.py
File metadata and controls
67 lines (44 loc) · 1.02 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# coding: utf-8
# In[3]:
largest = None
smallest = None
while True:
num = input("Enter a number: ")
try:
if (num == "done") : break
num = int(num)
if (largest is None):
largest = num
if (smallest is None):
smallest = num
if (num < smallest):
smallest = num
if (num > largest):
largest = num
except:
print ("Not a valid number!")
print ("Maximum is", largest)
print ("Minimum is", smallest)
# In[ ]:
# In[5]:
largest = None
smallest = None
while True:
num = input("Enter a number: ")
if num == 'done' : break
try:
num = int(num)
except:
print ("Invalid input")
continue
if (largest is None):
largest = num
if (smallest is None):
smallest = num
if (num < smallest):
smallest = num
if (num > largest):
largest = num
print ('Maximum is', largest)
print ('Minimum is', smallest)
# In[ ]: