Advertisement
Guest User

Untitled

a guest
Apr 1st, 2020
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. numList = list(range(1,101))
  2. numList2 = list(range(1,201))
  3.  
  4. totalSum = 0
  5. partialSumIndex = 0
  6.  
  7. selection = "0"
  8.  
  9. def gaussAdd(list):
  10. while len(list) > 0:
  11. intTwo = list.pop
  12. intOne = list.pop(0)
  13. intSum = intOne + intTwo
  14. totalSum += intSum
  15. partialSumIndex += 1
  16. print("%d + %d = %d" % (intOne, intTwo, intSum))
  17. print("%d will be added to the total." % intSum)
  18. print("The partial sum index has increased to %d." % partialSumIndex)
  19. print("The total sum of all numbers in the given list is %d." % totalSum)
  20.  
  21. while selection != 1 or 2:
  22. print("Choose a list to summarize using Gaussians additions.")
  23. selection = input("Type 1 for the 1-100 range, type 2 for the 1-200 range:")
  24. if selection == '1':
  25. gaussAdd(numList)
  26. elif selection == '2':
  27. gaussAdd(numList2)
  28. else:
  29. 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