-
Notifications
You must be signed in to change notification settings - Fork 2
/
exe_114_negatives_zeros_positives.py
48 lines (34 loc) · 1.3 KB
/
exe_114_negatives_zeros_positives.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
"""
The program receives INTEGERS from the USER UNTIL a BLANK LINE is ENTERED.
After that, the program displays ALL of the NEGATIVE NUMBERS,
followed by ALL of the ZEROS, followed by ALL of the POSITIVE NUMBERS.
WITHIN EACH GROUP the NUMBERS is DISPLAYING in the SAME ORDER (each value on its own line)
that they WERE ENTERED by the USER.
For example: 3,-4,1,0,-1,0,-2,"" -> -4,-1,-2,0,0,3,1
"""
# START Definition of the FUNCTION
def checkEntry(number): # Possible evolution -> IMPORT module
# Check Entry -> INTEGER
return True
# END Definition of FUNCTION
# START MAIN PROGRAM
def main():
# EMPTY LISTS within an EMPTY LIST
numbers = [[], [], []] # [ [negatives] , [zeros] , [positives] ]
# Acquisition and Control of the DATA entered by the USER
number = input("Enter the NUMBER (blank line to quit): ")
while number != "":
number = int(number)
if number < 0:
numbers[0].append(number)
elif number == 0:
numbers[1].append(number)
else: # number > 0
numbers[2].append(number)
number = input("Enter the NUMBER (blank line to quit): ")
# Displaying the RESULTS
for list_number in numbers:
for number in list_number:
print(number)
if __name__ == "__main__":
main()