Question

Write a program that prints the numbers from 1 to 100. But for multiples of three...

Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”.

Hints:

  • You can use a for loop with a range to simplify the iteration
  • Use the modulo division operator (%) to find the remainder of a division calculation
0 0
Add a comment Improve this question Transcribed image text
Answer #1
for i in range(1, 101):
    if i % 3 == 0 and i % 5 == 0:
        print("FizzBuzz")
    elif i % 3 == 0:
        print("Fizz")
    elif i % 5 == 0:
        print("Buzz")
    else:
        print(i)

Add a comment
Know the answer?
Add Answer to:
Write a program that prints the numbers from 1 to 100. But for multiples of three...
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
  • Write a C program that prints the numbers from 1 to 100. But for multiples of...

    Write a C program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.

  • Write a C program that prints the numbers from 1 to 100, but substitutes the word...

    Write a C program that prints the numbers from 1 to 100, but substitutes the word “fizz” if the number is evenly divisble by 3, and “buzz” if the number is divisible by 5, and if divisible by both prints “fizz buzz” like this: 1 2 fizz 4 buzz fizz 7 8 fizz buzz 11 fizz 13 14 fizz buzz 16 17 fizz 19 buzz ... and so on

  • java programming. hint: please use if-else method. Need to print numbers 1..100 For multiples of 3,...

    java programming. hint: please use if-else method. Need to print numbers 1..100 For multiples of 3, print "Fizz" instead of the number For multiples of 5. print "Buzz" instead of the number For multiples of 3 and 5, print "FizzBuzz" instead of the number For others, just print the number.

  • Python: Using your favorite text editor, write a program that outputs the string representation of numbers...

    Python: Using your favorite text editor, write a program that outputs the string representation of numbers from 1 to n. But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”. For numbers which are multiples of both three and five output “FizzBuzz”. Submit by uploading a .py file Example: n = 15, Return: [ "1", "2", "Fizz", "4", "Buzz", "Fizz", "7", "8", "Fizz", "Buzz", "11", "Fizz", "13", "14", "FizzBuzz"...

  • Use Python3 Write a program that prints the numbers from 1 up to 105 (inclusive), one...

    Use Python3 Write a program that prints the numbers from 1 up to 105 (inclusive), one per line. However, there are three special cases where instead of printing the number, you print a message instead: 1. If the number you would print is divisible by 3, print the message: The dog of wisdom knows all about this number. 2. If the number you would print is divisible by 7, print the message: Hold on I have a meme for this....

  • Homework - Topic 1 - Print 1 to 100: Write a program that prints the numbers...

    Homework - Topic 1 - Print 1 to 100: Write a program that prints the numbers from 1 to 100 with five values per line, two blank spaces between values. The last few lines will look like this: 91 92 93 94 95 96 97 98 99 100 using exclipse without it

  • please help me by matlab 5.2) Develop a program that prompts the user for three numbers....

    please help me by matlab 5.2) Develop a program that prompts the user for three numbers. Once received, print the multiplication of the first two numbers. Use the third number as the quantity of decimal places to print. 5.3) Develop a program that prompts the user for two numbers and a calculation operator (+,-/or *). Once received, use appropriate IF STATEMENTS to complete the calculation guided by the following rules: Addition Subtraction Division Multiplication Print to output to three decimal...

  • (1) Read in a number from the user that is in the ranger 1-200. If the...

    (1) Read in a number from the user that is in the ranger 1-200. If the user inputs a number out of that range, print out:Invalid number, try again. and read in a number until a valid one is produced. (2) Print out the numbers from 1 to userInput but: If a number is divisible by 3, print Fizz instead If a number is divisible by 5, print Buzz instead If a number is divisible by both 3 and 5,...

  • C++ Font Exercise #5: Multiples of a Number Write a C++ program that prompts the user...

    C++ Font Exercise #5: Multiples of a Number Write a C++ program that prompts the user to enter three integers, n, m, and k, where n is the lower limit, m is the upper limit of a range of positive numbers, and k is any positive number. The program then prints all multiples of the number k between n and m. Treb Sample input/ output: Charac nter the lower and upper limits: 12 93 Enter the multiple: 7 the multiples...

  • 1- Write a program to read 10 numbers and find the average of these numbers. Use...

    1- Write a program to read 10 numbers and find the average of these numbers. Use a while loop to read these numbers and keep track of input numbers read. Terminate the while loop with a sentinel value. 2- Now modify the program to find the maximum of these numbers as well. The program should print the number of elements read as input and run until -1 is entered. (-1 is the sentinel that terminates the loop and the program)...

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
ADVERTISEMENT