Skip to content

Commit c00abac

Browse files
author
Mark Charlton
committed
Wk5 Assignments
1 parent ddca712 commit c00abac

File tree

138 files changed

+3584
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+3584
-0
lines changed

.history/Assessment/Wk5/average_pos_neg_20230310000223.py

Whitespace-only changes.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Loop to handle 10 integer input and do maths.
2+
3+
l_pos=[]
4+
l_neg=[]
5+
6+
for i in range(10):
7+
tmp_in = int( input( f"Please enter integer [{i+1}/10]: ") )
8+
if tmp_in > int(0):
9+
l_pos.append(tmp_in)
10+
else:
11+
l_neg.append(tmp_in)
12+
13+
print ( f"Using the negative values {sorted(l_neg)} and positive values {sorted(l_pos)} " )
14+
print ( f'The sum of the negative values is: {sum(l_neg)}')
15+
print ( f'The sum of the positive values is: {sum(l_pos)}')
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Loop to handle 10 integer input and do maths.
2+
3+
import statistics as s
4+
5+
l_pos=[]
6+
l_neg=[]
7+
8+
for i in range(10):
9+
tmp_in = int( input( f"Please enter integer [{i+1}/10]: ") )
10+
if tmp_in > int(0):
11+
l_pos.append(tmp_in)
12+
else:
13+
l_neg.append(tmp_in)
14+
15+
if l_neg.count() > 0 :
16+
print ( f"Using the negative values {sorted(l_neg)}" )
17+
print ( f'The sum of the negative values is: {sum(l_neg)}')
18+
print ( f'The average of the negative values is: {s.mean(l_pos)}')
19+
else :
20+
print ( "There were no negative numbers entered")
21+
22+
if l_pos.count() > 0 :
23+
print ( f"Using the negative values {sorted(l_neg)} and positive values {sorted(l_pos)} " )
24+
print ( f'The sum of the positive values is: {sum(l_neg)}')
25+
print ( f'The average of the positive values is: {s.mean(l_pos)}')
26+
else :
27+
print ( "There were no positive numbers entered")
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Loop to handle 10 integer input and do maths.
2+
3+
import statistics as s
4+
5+
l_pos=[]
6+
l_neg=[]
7+
8+
for i in range(10):
9+
tmp_in = int( input( f"Please enter integer [{i+1}/10]: ") )
10+
if tmp_in > int(0):
11+
l_pos.append(tmp_in)
12+
else:
13+
l_neg.append(tmp_in)
14+
15+
if l_neg.count() > 0 :
16+
print ( f"Using the negative values {sorted(l_neg)}" )
17+
print ( f'The sum of the negative values is: {sum(l_neg)}')
18+
print ( f'The average of the negative values is: {s.mean(l_pos)}')
19+
else :
20+
print ( "There were no negative numbers entered")
21+
22+
if l_pos.count() > 0 :
23+
print ( f"Using the positive values {sorted(l_pos)} " )
24+
print ( f'The sum of the positive values is: {sum(l_neg)}')
25+
print ( f'The average of the positive values is: {s.mean(l_pos)}')
26+
else :
27+
print ( "There were no positive numbers entered")
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Loop to handle 10 integer input and do maths.
2+
3+
import statistics as s
4+
5+
l_pos=[]
6+
l_neg=[]
7+
8+
for i in range(10):
9+
while True:
10+
try:
11+
tmp_in = int( input( f"Please enter integer [{i+1}/10]: ") )
12+
break
13+
except ValueError:
14+
print ( "Invalid entry ")
15+
except:
16+
print ( "An unknown error occurred ")
17+
18+
if tmp_in > int(0):
19+
l_pos.append(tmp_in)
20+
else:
21+
l_neg.append(tmp_in)
22+
23+
if l_neg.count() > 0 :
24+
print ( f"Using the negative values {sorted(l_neg)}" )
25+
print ( f'The sum of the negative values is: {sum(l_neg)}')
26+
print ( f'The average of the negative values is: {s.mean(l_pos)}')
27+
else :
28+
print ( "There were no negative numbers entered")
29+
2
30+
if l_pos.count() > 0 :
31+
print ( f"Using the positive values {sorted(l_pos)} " )
32+
print ( f'The sum of the positive values is: {sum(l_neg)}')
33+
print ( f'The average of the positive values is: {s.mean(l_pos)}')
34+
else :
35+
print ( "There were no positive numbers entered")
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Loop to handle 10 integer input and do maths.
2+
3+
import statistics as s
4+
5+
l_pos=[]
6+
l_neg=[]
7+
8+
for i in range(10):
9+
while True:
10+
try:
11+
tmp_in = int( input( f"Please enter integer [{i+1}/10]: ") )
12+
break
13+
except ValueError:
14+
print ( "Invalid entry ")
15+
except:
16+
print ( "An unknown error occurred ")
17+
18+
if tmp_in > int(0):
19+
l_pos.append(tmp_in)
20+
else:
21+
l_neg.append(tmp_in)
22+
23+
if len(l_neg) > 0 :
24+
print ( f"Using the negative values {sorted(l_neg)}" )
25+
print ( f'The sum of the negative values is: {sum(l_neg)}')
26+
print ( f'The average of the negative values is: {s.mean(l_pos)}')
27+
else :
28+
print ( "There were no negative numbers entered")
29+
2
30+
if len(l_pos) > 0 :
31+
print ( f"Using the positive values {sorted(l_pos)} " )
32+
print ( f'The sum of the positive values is: {sum(l_neg)}')
33+
print ( f'The average of the positive values is: {s.mean(l_pos)}')
34+
else :
35+
print ( "There were no positive numbers entered")
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Loop to handle 10 integer input and do maths.
2+
3+
import statistics as s
4+
5+
l_pos=[]
6+
l_neg=[]
7+
8+
for i in range(10):
9+
while True:
10+
try:
11+
tmp_in = int( input( f"Please enter integer [{i+1}/10]: ") )
12+
break
13+
except ValueError:
14+
print ( "Invalid entry ")
15+
except:
16+
print ( "An unknown error occurred ")
17+
18+
if tmp_in > int(0):
19+
l_pos.append(tmp_in)
20+
else:
21+
l_neg.append(tmp_in)
22+
23+
if len(l_neg) > 0 :
24+
print ( f"Using the negative values {sorted(l_neg)}" )
25+
print ( f'The sum of the negative values is: {sum(l_neg)}')
26+
print ( f'The average of the negative values is: {s.mean(l_pos)}')
27+
else :
28+
print ( "There were no negative numbers entered")
29+
30+
print ("")
31+
32+
if len(l_pos) > 0 :
33+
print ( f"Using the positive values {sorted(l_pos)} " )
34+
print ( f'The sum of the positive values is: {sum(l_neg)}')
35+
print ( f'The average of the positive values is: {s.mean(l_pos)}')
36+
else :
37+
print ( "There were no positive numbers entered")
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Loop to handle 10 integer input and do maths.
2+
3+
import statistics as s
4+
5+
l_pos=[]
6+
l_neg=[]
7+
8+
for i in range(10):
9+
while True:
10+
try:
11+
tmp_in = int( input( f"Please enter integer [{i+1}/10]: ") )
12+
break
13+
except ValueError:
14+
print ( "Invalid entry ")
15+
except:
16+
print ( "An unknown error occurred ")
17+
18+
if tmp_in > int(0):
19+
l_pos.append(tmp_in)
20+
else:
21+
l_neg.append(tmp_in)
22+
23+
if len(l_neg) > 0 :
24+
print ( f"Using the negative values {sorted(l_neg)}" )
25+
print ( f'The sum of the negative values is : {sum(l_neg):8}')
26+
print ( f'The average of the negative values is: {s.mean(l_pos):8}')
27+
else :
28+
print ( "There were no negative numbers entered")
29+
30+
print ("")
31+
32+
if len(l_pos) > 0 :
33+
print ( f"Using the positive values {sorted(l_pos)} " )
34+
print ( f'The sum of the positive values is : {sum(l_neg):8}')
35+
print ( f'The average of the positive values is: {s.mean(l_pos):8}')
36+
else :
37+
print ( "There were no positive numbers entered")
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Loop to handle 10 integer input and do maths.
2+
3+
import statistics as s
4+
5+
l_pos=[]
6+
l_neg=[]
7+
8+
for i in range(10):
9+
s_err=""
10+
while True:
11+
try:
12+
tmp_in = int( input( f"{s_err}Please enter integer [{i+1}/10]: ") )
13+
break
14+
except ValueError:
15+
s_err="Invalid entry! "
16+
except:
17+
s_err="An unknown error occurred! "
18+
19+
if tmp_in > int(0):
20+
l_pos.append(tmp_in)
21+
else:
22+
l_neg.append(tmp_in)
23+
24+
if len(l_neg) > 0 :
25+
print ( f"Using the negative values {sorted(l_neg)}" )
26+
print ( f'The sum of the negative values is : {sum(l_neg):8}')
27+
print ( f'The average of the negative values is: {s.mean(l_pos):8}')
28+
else :
29+
print ( "There were no negative numbers entered")
30+
31+
print ("")
32+
33+
if len(l_pos) > 0 :
34+
print ( f"Using the positive values {sorted(l_pos)} " )
35+
print ( f'The sum of the positive values is : {sum(l_neg):8}')
36+
print ( f'The average of the positive values is: {s.mean(l_pos):8}')
37+
else :
38+
print ( "There were no positive numbers entered")
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Loop to handle 10 integer input and do maths.
2+
3+
import statistics as s
4+
5+
l_pos=[]
6+
l_neg=[]
7+
8+
for i in range(10):
9+
s_err=""
10+
while True:
11+
try:
12+
tmp_in = int( input( f"{s_err}Please enter integer [{i+1}/10]: ") )
13+
break
14+
except ValueError:
15+
s_err="Invalid entry! "
16+
except:
17+
s_err="An unknown error occurred! "
18+
19+
if tmp_in > int(0):
20+
l_pos.append(tmp_in)
21+
else:
22+
l_neg.append(tmp_in)
23+
24+
if len(l_neg) > 0 :
25+
print ( f"Using the negative values {sorted(l_neg)}" )
26+
print ( f'The sum of the negative values is : {sum(l_neg):8}')
27+
print ( f'The average of the negative values is: {s.mean(l_neg):8}')
28+
else :
29+
print ( "There were no negative numbers entered")
30+
31+
print ("")
32+
33+
if len(l_pos) > 0 :
34+
print ( f"Using the positive values {sorted(l_pos)} " )
35+
print ( f'The sum of the positive values is : {sum(l_pos):8}')
36+
print ( f'The average of the positive values is: {s.mean(l_pos):8}')
37+
else :
38+
print ( "There were no positive numbers entered")

0 commit comments

Comments
 (0)