SME
Engineering Programming (MATLAB/Python) · Problem type
Trace a while loop
Use this for “What is x after while x <= 20, x = 2*x runs from x = 1? How many passes?”
Explore
The first two lines set x to 1 and the pass count n to 0.
Assumptions
•
The test is read before every pass; the body runs only while it holds.
•
MATLAB ends the loop with end; Python ends it where the indent stops.
•
Each row of the table is the values after one pass of the body.
Topic check
See what you know: 5 questions on this topic
New questions each time. Pass to mark it complete.