-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsum_up_input.py
More file actions
56 lines (40 loc) · 1.72 KB
/
Copy pathsum_up_input.py
File metadata and controls
56 lines (40 loc) · 1.72 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
#!/usr/bin/env python
'''a program that sums a series of (positive) integers entered by the user,
excluding all numbers that are greater than 100
'''
# Init
the_total = 0
sum_up = True
while sum_up == True:
if the_total == 0:
try:
print('Enter 0 to EXIT')
integer_for_addition = int(input('Enter First number to add:'))
if integer_for_addition in range(1, 101):
print(the_total, '+', integer_for_addition ,'=', the_total + integer_for_addition )
the_total += integer_for_addition
elif integer_for_addition == 0:
print('Total:', the_total)
sum_up = False
else:
print('Please provide an integer under 100')
print('Current total:', the_total)
except ValueError:
print('Please enter an integer!!!!!')
print('Current total:', the_total)
else:
try:
print('Enter 0 to EXIT')
integer_for_addition = int(input('Enter number to add: '))
if integer_for_addition in range(1, 101):
print(the_total, '+', integer_for_addition ,'=', the_total + integer_for_addition )
the_total += integer_for_addition
elif integer_for_addition == 0:
print('Total:', the_total)
sum_up = False
else:
print('Please provide an integer under 100')
print('Current total:', the_total)
except ValueError:
print('Please enter an integer!!!!!')
print('Current total:', the_total)