Question: BlockPy: # 4 5 . 1 ) No While Loops Replace the while below with a for loop by using the built - in function

BlockPy: #45.1) No While Loops
Replace the while below with a for loop by using the built-in function range, which consumes a number and returns a list up to that number but not including it. For example, range (5) returns the list 0,1,2,3,4. In the end, the code should print out the sum of the numbers from 0 to 99(so your rnge function should go up to 100).
Console:
4950
Feedback:
May Not Use Code
You used a while loop on line 3. You may not use that.
Evaluate
Run
Blocks
Split
-= Text
Reset
Import datasets
G Upload
3 History
Variables
Decisions
Iteration
Functions
Calculation
Output
Input
Turtles
Values
Conversion
set sum_of_n =s2umofn
increase
index - by
1
1 sum_of_n =0
2 index =0
3 while index 100:
4 sum_of_n = sum_of_n + index
5 index +=1
6 print(sum_of_n)
View Trace
 BlockPy: #45.1) No While Loops Replace the while below with a

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!