List: sum of all

Sum of all items in a list

More for loops

 

###################################
#
#  tally.py
#  
#  Mrs. Elia
#  12/12
#  for loops: find the sum of all the
#  numbers in the list
#
###################################


aSeq = [8,6,3,2,10]
tally = 0

for i in aSeq:
    tally += i
print ("The total of all the items in the list ", aSeq, "is ", tally)


##>>> 
##The total of all the items in the list  [8, 6, 3, 2, 10] is  29
##>>> 

Class work:

Write a python program, Tally1_YI.py to find the sum of the numbers from x to y where x and y are two numbers the user inputs. Your program should prompt the user for x and y. Make sure your program checks x is smaller than y.

Write a python program, Tally2_YI.py to find the sum and the average of the following list: [45,23,76,18,90,123,56,76,89,22,41,56]
The output should look like this:
The sum of all the items in this list [45,23,76,18,90,123,56,76,89,22,41,56] is xxx and the average is xxx.xx.