This Python code uses a while loop to sum the integers from 1 to 20. It initializes a total and counter variable i to 0 and 1 respectively. The code iterates from i to 20, adding the current i to the running total on each loop. After the loop, it prints the final total.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
47 views
While Sum - Py
This Python code uses a while loop to sum the integers from 1 to 20. It initializes a total and counter variable i to 0 and 1 respectively. The code iterates from i to 20, adding the current i to the running total on each loop. After the loop, it prints the final total.