Answer to Question #291324 in Python for Sky

Question #291324


part 1: Citizens-of-Zakadaha-hold-an-annual-Gagalafa-festival-to-celebrate-the-harvest-of-their-prized-produce, the-well-sought-after-cocoa-beans-Kokomoko. A-lucky-draw-is-held during-the-festival. Every-participant-is-given-a-lucky draw number. Each year, the organizer decides on two non-zero digits, the factor-digit and the must-have-digit. These two digits need not be distinct. A winning lucky draw number is a number that is a multiple of the factor-digit and contains the must-have-digit. Note that there could be more than one lucky draw winner.

Write function find_winners(factor, must_have, n) that accepts the three parameters:

  1. The factor-digit (factor), a non-zero digit (1-9).
  2. The must-have-digit (must_have), a non-zero digit (1-9).
  3. The number of participants (n) where the lucky draw numbers will be numbered from 1 to n (inclusive).
1
Expert's answer
2022-01-27T18:29:48-0500
def find_winners(factor, must_have, n):
    for i in range(1, n + 1):
        if i % factor == 0 and str(must_have) in str(i):
            print('{} is a lucky number'.format(i))
find_winners(2, 3, 50)

30 is a lucky number
32 is a lucky number
34 is a lucky number
36 is a lucky number
38 is a lucky number

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS