FizzBuzz In Python
Recently I started looking for a new role, a new developer role. During my interviews, I have come across a number of questions and coding challenges. For each of these challenges, I take my time, create the code. I then come home and revisit that challenge to write a better solution.
In this new solution I create it in a few different languages, just to challenge myself, but to also provide my solution to anyone who maybe looking for the solution the this quiz question.
For this challenge I take one of the common coding quizzes I've seen asked during an interview is the FizzBuzz code question.
What is FizzBuzz? Simply put, its a challenge that will print one of 3 words when a number is divisible by a given number, and if not divisible it will output the number.
So, it seems common to give the following parameters:
Given the above parameters, here is my solution for this FizzBuzz challenge written in Python
def fizz_buzz(count):
found = False
for current_value in range(1, count+1):
output_string = ""
if current_value % 3 == 0:
output_string = "Fizz"
found = True
if current_value % 5 == 0:
output_string += "Buzz"
found = True
if found == False:
output_string = current_value
print(output_string)
found = False
fizz_buzz(100) I've also posted a video on YouTube of this solution if you wanted to see me talk through this code. Check out the video linked below.
So, to set the scene. I'm currently away on a break. I was out walking…
Creating a WordPress SEO plugin from scratch is an ambitious yet rewarding endeavor that can…
Introduction to API Endpoint Development Understanding API Endpoints API endpoints serve as the communicative bridges…
The innate human desire to learn and grow is a fundamental part of our nature.…
When working within the Spring framework, developers often encounter scenarios where transactional integrity is crucial…
Introduction to @Autowired in Java Spring Boot What is Dependency Injection? Dependency Injection (DI) is…