Skip to content

Commit f2be7b7

Browse files
authoredJul 13, 2021
Create valid_number.py
1 parent 5f28001 commit f2be7b7

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
 

‎valid_number.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Starting Out with Python (4th Edition).
2+
# Tony Gaddis.
3+
# Page 424.
4+
# Q. 1 Valid Number Information.
5+
6+
numbers = [74, 19, 105, 20, -2, 67, 77, 124, -45, 38]
7+
numbers.sort()
8+
print('Numbers = ', numbers)
9+
valid_numbers = []
10+
11+
for x in numbers:
12+
if x >= 0:
13+
valid_numbers.append(x)
14+
valid_numbers.sort()
15+
print('Valid Numbers = ', valid_numbers)
16+
17+
total = 0
18+
for x in valid_numbers:
19+
total += x
20+
21+
print('Total = ', total)
22+
average = total/len(valid_numbers)
23+
print('Average = ', average)

0 commit comments

Comments
 (0)
Please sign in to comment.