Avatar of the person chatting

Write a program to count the sum of first 100 numbers in phyton

Here's one way to write a program in Python to count the sum of the first 100 numbers:

# define a variable to store the sum sum = 0 # use a for loop to iterate through the numbers from 1 to 100 for i in range(1, 101): # add the current number to the sum sum += i # print the final sum print(sum)

This program uses a for loop to iterate through the numbers from 1 to 100. On each iteration, it adds the current number to the sum variable. At the end of the loop, the sum variable contains the total sum of the first 100 numbers, which is printed to the console.