Coding Fizzbuzz in Python 3 | Python Tutorial for Beginners
👇 Solution Code provided below CORRECTION: At 8:08 and 11:50 3x5x7 is NOT 210. It is 105 of which 210 is a multiple so the code is still correct. In this video we will cover the classic coding interview question Fizzbuzz, which was designed to weed out those that can't their way out of a paper bag. Don't be that guy! Then later we will take the difficulty up a notch by adding extra conditions which will force us to write better code. Subscribe to Apptato for more Python Tutorial for Beginners and coding interview questions! 💻 FizzBuzz : For x from 1 to N: If: x multiple of 3 "Fizz" x multiple of 5 "Buzz" x multiple of 3 & 5 "FizzBuzz" Else: x Output: 1, 2, Fizz, 4, Buzz, ..., 14, FizzBuzz [Code] def fizzbuzz(n): for x in range(1,n+1): if (x % 15 == 0): print ("fizzbuzz") elif (x % 3 == 0): print ("fizz") elif (x % 5 == 0): print ("buzz") else: print (x) 💻 FizzBuzzTuna : For x from 1 to N: If: x multiple of 3 "Fizz" x multiple of 5 "Buzz" x multiple of 7 "Tuna" x multiple of 3 & 5 "FizzBuzz" x multiple of 3 & 7 "FizzTuna" x multiple of 5 & 7 "BuzzTuna" x multiple of 3, 5 & 7 "FizzBuzzTuna" Else: x Output: 1, 2, Fizz, 4, Buzz, ..., 14, FizzBuzz [Code] def fizzbuzztuna(n): for x in range(1,n+1): string = "" if (x % 3 == 0): string += "fizz" if (x % 5 == 0): string += "buzz" if (x % 7 == 0): string += "tuna" if (string == ""): string = x print (string) 🔗 Links: Website: http://www.apptato.com YouTube: https://www.youtube.com/apptato Twitter: https://www.twitter.com/apptato Facebook: https://www.facebook.com/apptato Instagram: https://www.instagram.com/apptato #CODE #PYTHON #PROGRAMMING
Download
0 formatsNo download links available.