Question

Write a python function named displayFizzBuzz that takes a number as a parameter and DISPLAYS the...

Write a python function named displayFizzBuzz that takes a number as a parameter and DISPLAYS the appropriate FizzBuzz value for that number. Test this function on all of the numbers between 1 and 100000. Submit the code and a screenshot of the program running in Linux

0 0
Add a comment Improve this question Transcribed image text
Answer #1

chk out the solution and do comment if any queries.

-----------------------

# function definition
def displayFizzBuzz(n):
# if number is divisible by both 5 and 3 then it must be divisible by 15
# if tru then print fizzbuzz
if n%15 == 0:
print("FizzBuzz")
# if divisible only by 3 then print appropriately
elif n%3 == 0:
print("Fizz")
# if divisible only by 5 then print appropriately
elif n%5 == 0:
print("Buzz")
# else print the number itself
else:
print(n)
  
# loop from 1 to 100000
for i in range(1, 100000):
# function call and test the function for the given numbers
displayFizzBuzz(i)

----------------------------------

Code :

-------------

Output : a part of output pasted here.

Add a comment
Know the answer?
Add Answer to:
Write a python function named displayFizzBuzz that takes a number as a parameter and DISPLAYS the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT