Python for beginners multiples

<%= @topic_view.topic.title %>
<%= @topic_view.topic.average_rating %> <%= @topic_view.topic.posts.count { |p| !!p.custom_fields['rating'] } %>

Hey,guys,could you explain,why multiples are “num*2”,"num*3" is it by default in Python that multiples are identified in such a way?And how does Python identify that when we put (num*2) he should look for 20,(num*3)-30?Cause I did not get it,please

Multiples are really just the set of numbers that you get when you multiply a certain number by every integer. If you have a number, say 3, its multiples are 3 itself (3 * 1), 6 (3 * 2), 9 (3 * 3), 12 and so on. It’s purely math, not Python-specific.

It depends on the values that you pass to the first_three_multiples function. On line 9 you’re setting its num parameter to be 10. Basically every instance of num in the function will be replaced by 10, and num * 2 becomes 20, and so on.

1 Like

OK,got it,thank you so much!