Write python code to add 10 numbers?

Certainly! Below is a simple Python program that adds 10 numbers provided by the user:

# Initialize a variable to hold the sum
total_sum = 0

# Loop to get 10 numbers from the user
for i in range(10):
    # Get user input
    number = float(input(f"Enter number {i + 1}: "))  # Using float to allow decimal numbers
    total_sum += number  # Add the number to the total sum

# Print the total sum
print(f"The total sum of the 10 numbers is: {total_sum}")

You can run this code in any Python environment. It will prompt you to enter ten numbers one by one, and finally, it will display the sum of those numbers.

Have your own question?

Ask the AI now