Skip to content

Commit cc467f2

Browse files
authored
Multiply, sum, average out list
1 parent 6a5b54c commit cc467f2

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

Multiples_sum_average

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#Assignment: Multiples, Sum, Average
2+
This assignment has several parts. All of your code should be in one file that is well commented to indicate what each block of code is doing and which problem you are solving. Don't forget to test your code as you go!
3+
4+
Multiples
5+
Part I - Write code that prints all the odd numbers from 1 to 1000. Use the for loop and don't use a list to do this exercise.
6+
7+
Part II - Create another program that prints all the multiples of 5 from 5 to 1,000,000.
8+
9+
Sum List
10+
Create a program that prints the sum of all the values in the list: a = [1, 2, 5, 10, 255, 3]
11+
12+
Average List
13+
Create a program that prints the average of the values in the list: a = [1, 2, 5, 10, 255, 3]#
14+
rage
15+
#multiples A
16+
for count in range(1, 1001, 2):
17+
print count
18+
19+
#multiples B
20+
for count in range(5,1000001,5):
21+
print count
22+
23+
#sum list
24+
my_numbers = [1, 2, 5, 10, 255, 3]
25+
sum = 0
26+
for i in my_numbers:
27+
sum += i
28+
print sum
29+
30+
#average list
31+
print sum/len(my_numbers)

0 commit comments

Comments
 (0)