FAQ: Conditionals & Logic - Logical Operators

This community-built FAQ covers the “Logical Operators” exercise from the lesson “Conditionals & Logic”.

Paths and Courses
This exercise can be found in the following Codecademy content:

FAQs on the exercise Logical Operators

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!
You can also find further discussion and get answers to your questions over in Language Help.

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head to Language Help and Tips and Resources. If you are wanting feedback or inspiration for a project, check out Projects.

Looking for motivation to keep learning? Join our wider discussions in Community

Learn more about how to use this guide.

Found a bug? Report it online, or post in Bug Reporting

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

If the student’s score is 100 or if he has a “Free Pass Card”, he gets an an “A+”. But if his score is from 70 to 99 he only passes. We have two variables: “score” and “hasFreePass”. There are two options of codes:

Option 1:

1 if score == 100 or hasFreePass then
2 print("You got an A+")
3 elseif score < 100 and score >= 70 then
4 print("You passed")
5 end

Option 2:

1 if score == 100 or hasFreePass then
2 print("You got an A+")
3 elseif score >= 70 then
4 print("You passed")
5 end

Notice the difference in “line 3”. Why shoud I do “Option 1”? I could simply do the “Option 2”, because elseif checks if the variable does not meet the “if” condition but meets its condition, so there is no need to use “and”! Well, the lesson tells me to do “Option 1”!

Accept what the lesson gives as a solution and your ability to find it; and, pat yourself on the back for refactoring. It’s the second skill one needs to learn after solving something in the first place. The course is what it is. What you do with it is up to you. Keep this in mind and don’t expect every lesson to be an exhaustive expose of the concept. All in stride, and all the more reason to expect to advance on what you have learned.

1 Like

Well… true… I lost a lot a time trying to find out, and, when I forgot this and kept doing other lessons and just then realized that it was not the course’s error: I have forgotten a important detail! It was my error! Well, thank you, helped me a lot! :confused: :confused:

1 Like