-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContinue and Break.py
97 lines (87 loc) · 2.11 KB
/
Continue and Break.py
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# continue is used to skip current iteration in a loop when condition is met
# break us used to get out of the loop when condition is met
# for i in range(1,101):
# if i % 2 == 0:
# continue # skips even numbers
# else:
# print(i)
#
# print("---")
#
# for i in range(1,10):
# if i == 5:
# break
# print(i)
# print("THE END")
#
# def numbers_divisible_byfive(p_list):
# for i in p_list:
# if i % 5 == 0:
# print(i)
# if i > 130:
# break
# print("STOP")
#
# p_list = [12, 15, 32, 40, 52, 75, 122, 132, 150, 180, 200]
# numbers_divisible_byfive(p_list)
# def factorial(p_num):
# a = 1
# if p_num < 0:
# return "Factorial does not exist for negative numbers"
# elif p_num == 0:
# return "The factorial of 0 is 1"
# else:
# for num in range(1,p_num+1):
# a = a * num
# return f"The factorial of {p_num} is {a}"
#
# print(factorial(5))
# def check_for_float(p_input):
# try:
# val = float(p_input)
# return val
# except ( ValueError, TypeError):
# print("Error, please enter numeric input")
# return False
#
# count = 0
# total = 0.0
# average = 0.0
#
# while True:
# input_number = input("Enter a number: ")
# if input_number == "done":
# break
#
# number = check_for_float(input_number)
# if not number:
# continue
#
# count +=1
# total - total + number
# if count !=0:
# average = total / count
# print(total,count,average)
def check_for_float(p_input):
try:
val = float(p_input)
return val
except (ValueError, TypeError):
print("Error, please enter numeric input")
return False
in1 = input("Enter a number: ")
number = check_for_float(in1)
big = number
s = number
while True:
input_number = input("Enter a number: ")
if input_number == "done":
break
number = check_for_float(input_number)
if not number:
continue
if number > big:
big = number
elif number < s:
s = number
print(f"Maximum number: {big}, Minimum number: {s}")