Ad
Strings
Data Types
Iterators
Control Flow
Object-oriented Programming
Basic Language Features
Fundamentals
Programming Paradigms
Code
Diff
  • removeEverySecond = lambda string: string[::2]
    • def removeEverySecond(string):
    • a = list(string)
    • b = a[::2]
    • b= "".join(b)
    • return b
    • removeEverySecond = lambda string: string[::2]
Code
Diff
  • public class FizzBuzz
    {
        public string GetOutput(int number) {
          if (number % 15 == 0) {
            return "FizzBuzz";
          }
          else if (number % 3 == 0) {
            return "Fizz";
          }
          else if (number % 5 == 0) {
            return "Buzz";
          }
          else {
            return number.ToString();
          }
          // Fizz buzz is a popular computer science interview question.  
          // The function above is given a number - if the number is
          // divisible by 3, return "fizz", if it's divisible by 5, 
          // return "buzz", if not divisble by 3 or 5 - return the
          // number itself.
        }
    }
    • public class FizzBuzz
    • {
    • public string GetOutput(int number) {
    • if (number % 3 == 0 && number % 5 == 0) {
    • if (number % 15 == 0) {
    • return "FizzBuzz";
    • }
    • else if (number % 3 == 0) {
    • return "Fizz";
    • }
    • else if (number % 5 == 0) {
    • return "Buzz";
    • }
    • else {
    • return number.ToString();
    • }
    • // Fizz buzz is a popular computer science interview question.
    • // The function above is given a number - if the number is
    • // divisible by 3, return "fizz", if it's divisible by 5,
    • // return "buzz", if not divisble by 3 or 5 - return the
    • // number itself.
    • }
    • }