Another beautiful day in this miserable world

Python Programming. Sum of a Series of Numbers


#Write a program to sum a series of numbers entered by the user.
#The program should first prompt the use for how many numbers are to be summer.
#It should then input each of the numbers and print a total sum.

def main():
    total = 0
    num = eval(input("How many numbers do you have? "))
    for i in range (num):
        ber = eval(input("What is your first number? "))
        total = ber + total

    print("The total value of your ", num, "numbers is ", total)

main()

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Tag Cloud

Follow

Get every new post delivered to your Inbox.