Question: Part 1 Write a loop that sums all positive integers from 1 to 100 Note: The answer is 5150 Print out the result in sentence

Part 1

Write a loop that sums all positive integers from 1 to 100

Note: The answer is 5150

Print out the result in sentence form such as:

The sum of all positive integers from 1 to 100 is 5150

Part 2

Make your loop interactive by allowing the user to choose the starting value and the ending value

Print out the results in sentence form

Part 1 Write a loop that sums all positive integers from 1to 100 Note: The answer is 5150 Print out the result in

Iteration Otherwise known as looping or repetition structure Why Would Want to do This? Sometimes you need to do something more than once The syntax of a while loop in Python programming language is while expression While expression true Do all indented statements statement (s) Here, statement (s) may be a single statement or a block of statements. The condition may be any expression, and true is any non-zero value. The loop iterates while the condition is true. When the condition becomes false, program control passes to the line immediately following the loop In Python, all the statements indented by the same number of character spaces after a programming construct are considered to b e part of a single block of code. Python uses indentation as it s method o grouping statements

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!