LeetCode: Fizz Buzz

Thank you for visiting this post! Be sure to also take a look at my other work on LinkedIn, Github, and my website.

Presenting an Algorithm you know and love; Please welcome the myth, the legend, the one and ONLY…FizzBuzz.

I’ve solved this problem before in JavaScript, but I have NEVER solved this using Python, which I’m in the process of learning.

Im going to show you both my solutions for this problem using JavaScript and Python. Let’s see how they compare with one another!

Problem

Please click the link below to view the Problem Statement

Solution

Above is my first JS solution for FizzBuzz. Let’s see how it compares to my Python Solution below.

Both solutions for Javascript and Python use a for loop and conditional statements. The syntax is a but different, but they essentially do the same thing.

The range() function returns a sequence of numbers, starting from 0 by default, and increments by 1 (by default), and ends at a specified number.

— W3 Schools

Rather than use else if like Javascript, Python uses elif. Both do the same thing!

Also, Python does not recognize ‘===’ like JavaScript does, but rather it uses ‘==’ only.

Conclusion

All in all, I had a lot of fun solving this. The more I progress in my learning of Python, the more I hope to write about the language.

Thank you so much for stopping by! Stay tuned for more Algorithm Content!

Please checkout my online portfolio and feel free to connect with me on Linkedin!

Sources:

https://www.w3schools.com/python/python_for_loops.asp#:~:text=The%20range()%20function%20returns,ends%20at%20a%20specified%20number.,

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Sentiment Analysis for Customer Experience With Python and Streamlit

Rename host-network-range objects according to standard which you made on Checkpoint Management

AppBridge Migration Integration with AODocs for Google G Suite

AODocsPressRelease_2016-12-02

App Modernization 2021: Innovation, Security, and Cost Savings

Continuing Database Harmonization Between Corda and Corda Enterprise

Announcing Feedback Bounty Hunt for Moloch March Testers

Why software engineering?

Meme: I’m sorry, is my teaching interrupting you?

Which videos should you watch from CloudNativeCon/KubeCon North America 2018?

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Stephanie Segura

Stephanie Segura

More from Medium

Comparing Insertion Sorting and Merge Sorting Algorithms

Stack Data Structures: A brief overview

A stack of pancakes

Programming: Array manipulation using recursion

Iterator Class For Inorder Traversal Of A Binary Tree