Python code
Write a complete program with for loop which calculates the sum of the numbers from 1 to 100
# create main function def main(): # set total to 0 first total = 0 for i in range(1, 101): # make a loop to go from 1 to 100 (101 is exclusive in range here) total += i # add that number to total print("Sum of the numbers from 1 to 100 is", total) # finally print the total # call the main function here main()
Get Answers For Free
Most questions answered within 1 hours.