Pull Hook Mesh question
1. You first say three different special numbers, the requirements must be single-digit, such as 3, 5, 7.
2. Make a team of all the students and then count off the order.
3. When the student counts off, if the quoted figure is a multiple of the first special number (3), then the number should not be said, but fizz; if the quoted figure is a multiple of the second special number (5), then buzz; if the quoted number is a multiple of the third special number (7), say whizz.
4. When a student counts off, if the quoted number is also a multiple of two special numbers, also special treatment, such as the first special number and the second special number of multiples, then can not say the number, but to say Fizzbuzz, and so on. If it is also a multiple of three special numbers, say fizzbuzzwhizz.
5. When the student counts off, if the quoted number contains the first special number, then can not say the number, but to say the corresponding words, such as the first special number in this case is 3, then to report 13 of the students should say fizz. If the number contains the first special number, then ignore rules 3 and rule 4, for example, to report 35 of the students only reported fizz, do not report buzzwhizz.
Now, we need you to complete a program to simulate this game, it first accepts 3 special numbers, and then outputs 100 students should count off the number or word.
The code is as follows:
def check (A, DIC, D):
Answer = ' '
If Str (a) in Str (d):
return Dic[a]
For x in DIC:
If not (d% x):
Answer = answer + dic[x]
If not answer:
Return D
Return answer
if __name__ = = ' __main__ ':
a = Int (raw_input (' Input u A: '))
b = Int (raw_input (' Input u B: '))
c = Int (raw_input (' Input u c: '))
DIC = {A: ' Fizz ', B: ' Buzz ', C: ' Whizz '}
For x in Xrange (1, 101):
Print Check (A, dic, X)
The code is as follows:
[' Fizz ' [(str (3) not in Str (i)] *4:]or ' Fizz ' [I% 3 * 5:] + ' Buzz ' [I% 5 * 5:] + ' whizz ' [I% 7 * 5:] or I-I in rang E (1,101)]