Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- numList = list(range(1,101))
- numList2 = list(range(1,201))
- totalSum = 0
- partialSumIndex = 0
- selection = "0"
- def gaussAdd(list):
- while len(list) > 0:
- intTwo = list.pop
- intOne = list.pop(0)
- intSum = intOne + intTwo
- totalSum += intSum
- partialSumIndex += 1
- print("%d + %d = %d" % (intOne, intTwo, intSum))
- print("%d will be added to the total." % intSum)
- print("The partial sum index has increased to %d." % partialSumIndex)
- print("The total sum of all numbers in the given list is %d." % totalSum)
- while selection != 1 or 2:
- print("Choose a list to summarize using Gaussians additions.")
- selection = input("Type 1 for the 1-100 range, type 2 for the 1-200 range:")
- if selection == '1':
- gaussAdd(numList)
- elif selection == '2':
- gaussAdd(numList2)
- else:
- print("I'm sorry, that's not a valid option. Please enter 1 or 2.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement