Exercise: Logical expressions
In this exercise, you'll define functions to return Boolean expressions based on input parameters. Before you start coding, remember to check the doctests for examples of what should return True
/False
. When you think you're done coding, run the tests to make sure they all pass.
Curly Hair Checker
📺 Need help getting started on this one? Watch me go through a similar problem in this video.
Or, if you'd like more guidance in written form, expand this block.
- Your function only needs a single line of code: one return statement.
- The return statement should contain a compound Boolean expression using
==
with theand
operator. - The Boolean expression should involve the parameters (
father_allele
,mother_allele
) as well as literal strings ("C"
).
For a code template, expand this block.
Fill in the blanks with the correct comparison and try running the tests.
return father_allele ______ and mother_allele ______
Presidential Eligibility
If you'd like more guidance, expand this block.
- Your function only needs a single line of code: one return statement.
- The return statement should contain a compound Boolean expression using
>=
with theand
operator. - The Boolean expression should involve the parameters (
age
,residency
) as well as literal numbers (35
,14
).
For a code template, expand this block.
Fill in the blanks with the correct comparison and try running the tests.
return ______ and ______
Seafood Safety
If you'd like more guidance, expand this block.
- Your function only needs a single line of code: one return statement.
- The return statement should contain a compound Boolean expression using
>=
,==
, with theor
operator. - The Boolean expression should involve the parameters (
seafood_type
,days_frozen
) as well as a literal number (7
) and a literalstring
("mollusk"
).
For a code template, expand this block.
Fill in the blanks with the correct comparison and try running the tests.
return ______ or ______