Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #98873

Re: A Program that prints the numbers from 1 to 100

Newsgroups comp.lang.python
Date 2015-11-16 03:57 -0800
References <ddada022-49a4-418e-85a1-45cd6da015f7@googlegroups.com>
Message-ID <85eea326-406d-4454-8c3a-859f1e464cfc@googlegroups.com> (permalink)
Subject Re: A Program that prints the numbers from 1 to 100
From harirammanohar159@gmail.com

Show all headers | View raw


On Saturday, 14 November 2015 23:04:40 UTC+5:30, Cai Gengyang  wrote:
> I want to write a program in Python that does this ----
> 
> "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". For numbers which are multiples of both three and five print "FizzBuzz"."
> 
> How do I go about doing it ?

This would help, but try to write on your own to improve, else you cant make this going long....

i = 1

while i <= 100:
    if multipleof_3 and multipleof_5:
        print("FizzBuzz")
        ++i
    elif multipleof_3:
        print("Fizz")
        ++i
    elif multipleof_5:
        print("Buzz")
        ++i
    else:
        print(number)
        ++i

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

A Program that prints the numbers from 1 to 100 Cai Gengyang <gengyangcai@gmail.com> - 2015-11-14 09:34 -0800
  Re: A Program that prints the numbers from 1 to 100 Joel Goldstick <joel.goldstick@gmail.com> - 2015-11-14 12:49 -0500
  Re: A Program that prints the numbers from 1 to 100 BartC <bc@freeuk.com> - 2015-11-14 18:18 +0000
    Re: A Program that prints the numbers from 1 to 100 Ammammata <ammammata@tiscalinet.it> - 2015-11-16 11:12 +0000
  Re: A Program that prints the numbers from 1 to 100 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-11-14 18:25 +0000
  Re: A Program that prints the numbers from 1 to 100 Steven D'Aprano <steve@pearwood.info> - 2015-11-15 12:39 +1100
  Re: A Program that prints the numbers from 1 to 100 harirammanohar159@gmail.com - 2015-11-16 03:57 -0800
    Re: A Program that prints the numbers from 1 to 100 Chris Angelico <rosuav@gmail.com> - 2015-11-16 23:35 +1100
      Re: A Program that prints the numbers from 1 to 100 Jussi Piitulainen <harvesting@is.invalid> - 2015-11-16 15:39 +0200
        Re: A Program that prints the numbers from 1 to 100 Chris Angelico <rosuav@gmail.com> - 2015-11-17 00:43 +1100

csiph-web