-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2. Multiple, Sum, Average
More file actions
31 lines (24 loc) · 965 Bytes
/
Copy path2. Multiple, Sum, Average
File metadata and controls
31 lines (24 loc) · 965 Bytes
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
#Assignment: Multiples, Sum, Average
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!
Multiples
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.
Part II - Create another program that prints all the multiples of 5 from 5 to 1,000,000.
Sum List
Create a program that prints the sum of all the values in the list: a = [1, 2, 5, 10, 255, 3]
Average List
Create a program that prints the average of the values in the list: a = [1, 2, 5, 10, 255, 3]#
rage
#multiples A
for count in range(1, 1001, 2):
print count
#multiples B
for count in range(5,1000001,5):
print count
#sum list
my_numbers = [1, 2, 5, 10, 255, 3]
sum = 0
for i in my_numbers:
sum += i
print sum
#average list
print sum/len(my_numbers)