-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpositive_vs_negative_ints.py
More file actions
31 lines (27 loc) · 927 Bytes
/
Copy pathpositive_vs_negative_ints.py
File metadata and controls
31 lines (27 loc) · 927 Bytes
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
#!/usr/bin/env python3
'''Positve Vs Negtive integers.
The user can enter any number of positive and negative integer values,
Displays the number of positive values entered, as well as the number
of negative values.
'''
# Init
positive_int_count = 0
negative_int_count = 0
terminate = False
while not terminate:
try:
print('Enter 0 to Finish')
the_value = int(input('Enter an interger: '))
if the_value > 0:
print(the_value, 'is positive')
positive_int_count += 1
elif the_value < 0:
print(the_value, 'is negative')
negative_int_count += 1
elif the_value == 0:
print('Positive integer count: ', positive_int_count)
print('Negative integer count: ', negative_int_count)
print('Exiting..............')
terminate = True
except ValueError:
print('Please provide integer')