sum of numbers 1 to 100 python code example

Example 1: python sum of 10 numbers from user input

a_list = []
print("Please enter 10 numbers with or without decimals\n")

for num in range(10):
    list_num = float(input("Enter a number:"))
    a_list.append(list_num)
print(sum(a_list))

Example 2: python sum of 10 numbers from user input

lst = []num = int(input('How many numbers: '))for n in range(num):    numbers = int(input('Enter number '))    lst.append(numbers)print("Sum of elements in given list is :", sum(lst))