thecodezone.
The Code Zone
Short steps, at your pace · Free lessons and practice · Member video walkthroughs
Save your next small win.

Checking your account…

01.02 · Conditions and decisions / Practice · 8 min

Make each condition express its rule

The weather values are correct, but the program is asking the wrong questions. Repair the expressions without changing its inputs.

Activity 2 of 9 in Conditions and decisions

All courses

Python 2: Logic, Loops & Functions / 01.02

Practice logical operators

Not started

Calculate both-ready, either-ready and not-ready results, then combine the picnic conditions.

More options

Your lesson progress

Walkthrough: not startedPractice: not started

Empty: not started. Yellow: in progress. Green: complete. Marking the whole activity complete does not replace your test results. These circles save in this browser for this pilot.

Rob checks sunny True and raining False, asks whether it is sunny and not raining, then sees True for the picnic rule.
Rob’s comic strip · Conditions and decisions

Four rules to check

Keep is_sunny assigned to True, is_warm assigned to False, is_raining assigned to False and is_snowing assigned to False. Replace the expressions assigned to the four answer variables. Keep the print calls in their existing order.

both_ready must ask whether it is sunny and warm. either_ready must ask whether it is sunny or warm. not_sunny must reverse is_sunny. can_picnic must require sunshine and neither rain nor snow. Use the input names in expressions instead of hardcoding answer values.

Check answers, then vary inputs

The checks compare the four input values, four stored Boolean answers and complete printed output for the starting inputs. They do not prove which operator you used. After passing, try is_raining = True: only can_picnic should change. Try is_warm = True: both_ready should change too. Restore the original inputs before running the fixed-input checks.

Build it one step at a time

Prefer learning by typing? Work through short instructions, run the Python code and check each change before continuing. Your guided project saves separately from the challenge below.

The mini-lesson opens in a new tab. Your own code carries forward; each step has a focused check and an optional hint.

Start mini-lesson(opens in a new tab)

4 steps · Saved work · Instant feedback

YOUR TURN

Choose the operator for each rule

Keep the four starting weather values. Calculate both_ready using and, either_ready using or, not_sunny using not, and can_picnic requiring sunshine and neither rain nor snow. Keep the print calls in order. Store actual Boolean values, not quoted words.

Expected output
False
True
False
True

Keep the starting inputs. Print these lines in this order, without extra output.

  • Keep is_sunny True
  • Keep is_warm False
  • Keep is_raining False
  • Keep is_snowing False
  • Both sunny and warm is False
  • Sunny or warm is True
  • Not sunny is False
  • Sunny without rain or snow allows the picnic

Edit Python, then run it. Check challenge checks your output and the listed Python requirements. Your code saves on this browser after a short pause. Sign in and choose Save account draft to keep it across devices. Word wrap is enabled.

Ready to checkRun the checks to see your results here.

Need a nudge?

Both is different from either

and requires both Boolean answers to be True. or accepts at least one True answer.

Reverse the grouped precipitation question

Ask is_raining or is_snowing inside parentheses. Use not before that group, then combine it with is_sunny using and.

Replace your editor code?

Your current work will be replaced. Choose Cancel to keep it.

Ready to try it?

Practice in your browser and see your results.

Progress details

Have a question?

Ask the Code Zone community.

Ask a question in The Code Zone (opens in a new tab)

Continue learning

ONE STEP FORWARD

You can now combine Boolean answers. Next comes choosing which indented instructions run with if, elif and else.