222k views
12 votes
given a number n for each integer i in the range from 1 to n inclusive print one value per line as follows fizzbuzz if __name__

User TheSpyCry
by
5.0k points

1 Answer

7 votes

Answer:

The program in Python is as follows:

def fizzBuzz(n):

for i in range(1,n+1):

print(i)

if __name__ == '__main__':

n = int(input().strip())

fizzBuzz(n)

Step-by-step explanation:

This declares the fizzBuzz function

def fizzBuzz(n):

This iterates from 1 to n

for i in range(1,n+1):

This prints every number in that range; one per line

print(i)

The main begins here

if __name__ == '__main__':

This prompts user for input

n = int(input().strip())

This calls the fizzBuzz function

fizzBuzz(n)

User Tacone
by
5.4k points