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
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.
Your lesson progress
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.

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.
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.
Your check results
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.
One possible solution
Your code may look different and still be correct. Compare the approach with your own.
and requires both answers, or allows either or both, and not reverses an answer. Parentheses make the picnic rule readable. Change the inputs to check that your expressions generalize.
is_sunny = True
is_warm = False
is_raining = False
is_snowing = False
both_ready = is_sunny and is_warm
either_ready = is_sunny or is_warm
not_sunny = not is_sunny
can_picnic = is_sunny and not (is_raining or is_snowing)
print(both_ready)
print(either_ready)
print(not_sunny)
print(can_picnic)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

7 days freeTry The Code Zone
THE CODE ZONE COMMUNITY
Your next step is easier together.
Try the community free for 7 days.
No charge during your trial. Choose your plan on Skool.
- Ask questions and get support in the community
- Watch every course video walkthrough
- Find a study buddy in the 24/7 study room
Make the most of your trial with Premium.
Choose Premium on Skool to try Thursday live help sessions. Bring your questions, work through code, and get unstuck together.
Scheduled Thursdays in Eastern Time. Check the Skool calendar for your local date and time.
Have a website account? Sign in