On 13Aug2015 10:34, ALAN GAULD <alan.ga...@btinternet.com> wrote:
On 13/08/15 02:01, IDN3 wrote:
[...snip...]
Condition: If c is less than 5, then the loop will continue; else, it will
end.

3.   *Problem 2:*Print a string variable that states the number of loops
required to meet the condition for Problem 1.

This is a simple bit of math.
You don't need to run the loop to figure out the answer,
just write an equation.

Maybe so, but for an arbitrarily weird condition running the loop may be the way to go. Therefore I would imagine he is being asked to print how many times that loop ran. So he should just print that value after the loop finishes (i.e outside the loop).

My attempt below.  I used a while loop even though the question is saying
IF/THEN/ELSE.

You obviously did not send the whole question.
I don't see any mention of if/then/else?

Actually, the question's "Condition:" section is written in exactly those terms.

To my knowledge loops in Python have to be while/for.  Also,
it seems like the question is missing some direction, but I could be
wrong.

The way I would read your "Cndition:" requirement is that it is describing what kind of decision must be made every time the loop commences. It is not telling you to use Pythons "if" statement. So just putting the correct condition at the top of the "while" loop is what you want.

Cheers,
Cameron Simpson <c...@zip.com.au>

If you lie to the compiler, it will get its revenge.    - Henry Spencer
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to