This community-built FAQ covers the “Multiple of Three” exercise from the lesson “Lambda Function Code Challenge”.
Paths and Courses
This exercise can be found in the following Codecademy content:
FAQs on the exercise Multiple of Three
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 () 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 () below!
Agree with a comment or answer? Like () to up-vote the contribution!
I believe that this exercise contains an error in the example. The examples explain how to use modulo in the following (among other) example:
12%5 #5 is not a multiple of 12
2
I think that the author of this got confused and wrote the # comment backwards. While it’s true that 5 is not a multiple of 12, that is not proven by 12%5. It would be proven by 5%12. Using the logic of the exercise, 12%24 would return a remainder of 12 and conclude that 24 is not a multiple of 12 when it is.
In short, and please correct me if I’m just misunderstanding this, x%5 == 0 proves that x is a multiple of 5; it does not prove that 5 is a multiple of x.
Hello, @web1233442072. Welcome to the forum. I believe you are correct. It should read that '5 is not a factor of 12' or '12 is not a multiple of 5'. If you can provide a link to the specific exercise, I’ll submit a bug report. Good catch!
The author might be unaware that while a learner is typing in the code, the editor is assuming the str() function, and auto-inserting that syntax. Would throw any learner for a loop. This should not be the recommended or instructed name to use in the code.
This is not on the topic, but on an earlier lesson leading up to it. I’m still not caught up yet.
Caught up. That is definitely a narrative issue. I’ve not seen the term, factor come up much. It does factor into this discussion, though; pun intended.
On the whole, we can complete this lesson, given our own intuition and can forgive the ambiguity in the narrative if we have our own wherewithal.
#Write your lambda function here
rate_movie = lambda rating: rating > 8.5 and "I liked this movie." or "This was not very good."
print rate_movie(9.2)
print rate_movie(7.2)
I liked this movie.
This was not very good.
This will not pass the pass the SCT. Still working on that.
I think the point is that they’re expressions, not that they are expressive. By being able to write function literals, they can be combined. Like with numbers. We have literals for those. 1 + 3
if_ = lambda cond: lambda a: lambda b: lambda x: cond(x) and a() or b()
gt = lambda b: lambda a: a > b
rate_movie = \
(if_
(gt(8.5))
(lambda: "I liked this movie")
(lambda: "This movie was not very good"))
print rate_movie(9.2)
print rate_movie(7.2)
Who needs built-in statements? Not us. Could even do away with the assignment statement. This is quickly becoming full-on lisp code…
OMG, are you trying to fry my mind? If so you are succeeding. Seriously, though, I am doing my best to follow along and love how you have this playing out. It’s poetry.
I had "not a multiple and “multiple of three” reversed and it was wrong. But if I’m looking at this logically by putting %3 against “print multiple_of_three(9)” it would seem more correct to have “Multiple of three” first. Doesnt %3 end with a 0 sum? The logic just seems backwards to me.