Skip to content

Instantly share code, notes, and snippets.

@princesanjivy
Created April 15, 2024 17:31
Show Gist options
  • Save princesanjivy/0f062144261e58268e7d9b3b8c482df1 to your computer and use it in GitHub Desktop.
Save princesanjivy/0f062144261e58268e7d9b3b8c482df1 to your computer and use it in GitHub Desktop.
Demo
a=int(input("Enter the number of terms: "))
k=0
print("Enter",a,"terms: ")
for i in range(1,a+1):
ai=int(input())
k+=ai
z=input("Enter 'A' if you want to get the Sum or Enter 'B' if you want to get the Average:")
if z=='A':
print("The Sum:",k)
elif z=='B':
print("The Average:",k/a)
else:
print("Invalid Option")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment