Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

FIZZBUZZ ALGORITHM

def fizz_buzz(input):
    if input % 3 == 0 and not input % 5 == 0:
        return "Fizz"
    if input % 5 == 0 and not input % 3 == 0:
        return "Buzz"
    if (input % 3 == 0) and (input % 5 == 0):
        return "FizzBuzz"

    return input

print(fizz_buzz(15))



# OR MORE SIMPLIFIED



def fizz_buzz(input):
    if (input % 3 == 0) and (input % 5 == 0):
        return "FizzBuzz"
    if input % 3 == 0:
        return "Fizz"
    if input % 5 == 0:
        return "Buzz"

    return input


print(fizz_buzz(15))
Comment

PREVIOUS NEXT
Code Example
Python :: looping through the dict. and return the key with the highest value 
Python :: bold colors in pytohn 
Python :: how to break out of while loop when the user hit ctrl + d python 
Python :: python raccourci mettre paragraphe commentaire 
Python :: python sort by last name using lambda 
Python :: For_else 
Python :: Understand the most appropriate graph to use for your dataset 
Python :: restart kernel python 
Python :: trivia python game 
Python :: frame work in turtle module 
Python :: 1042 uri solution 
Python :: Mapping using dictionary 
Python :: pyqt set widget size 
Python :: How to Merge QuerySets in Django Rest Framework 
Python :: image name validate using regex python 
Python :: captcha.image install in python 
Python :: qubesos 
Python :: how to get a rectangular grid out of two given one-dimensional arrays 
Python :: iptc text classification example 
Python :: python get text between two points 
Python :: expionenttiation python 
Python :: creer des disques en python tkinter 
Python :: sorting-a-dictionary-by-value-then-by-key 
Python :: how to take long input in python 
Python :: Return an RDD of grouped items. 
Python :: python download sklearm model.joblib from google stroage 
Python :: scrapy get raw html content of selector innerhtml 
Python :: restore tf model python ValueError: Unknown loss function:smoothL1 
Python :: how to make a dashboard with data representation using python free dash 
Python :: get derivative of interp1d 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =