Conditionals

The questions below are due on Friday June 21, 2024; 10:00:00 PM.
 
You are not logged in.

Please Log In for full access to the web site.
Note that this link will take you to an external site (https://shimmer.mit.edu) to authenticate, and then you will be redirected back to this page.

During a 6.s090 tutorial one day, a stranger walks in and asks to talk about Python conditionals. She is convinced that, if you have while available to you, there is actually no need to use if!

She argues that, everywhere you would write something like:

if <condition>:
    <body>

(with no matching else or elif) you could instead write:

have_done_it = False
while not have_done_it and <condition>:
    <body>
    have_done_it = True

and the results of running your code would not change!

Is she correct? If so, briefly explain why. If not, provide a counter-example and briefly explain why it does not work.

Formatting Help

Next Exercise: Survey

Back to exercises