Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2014 Integration Services

Authors: Brian Knight, Devin Knight

1st Edition

1118850904, 9781118850909

More Books

Students also viewed these Databases questions

Question

What property does the correlation coefficient measure?

Answered: 1 week ago