Skip to Content
Build a Career in Data Science
book

Build a Career in Data Science

by Emily Robinson, Jacqueline Nolis
March 2020
Beginner
354 pages
13h 34m
English
Manning Publications
Content preview from Build a Career in Data Science

A.1. Coding and software development

A.1.1. FizzBuzz

Write a program that prints the numbers 1 to 100. But for multiples of 3, print "Fizz" instead of the number, and for the multiples of 5, print "Buzz". For numbers that are multiples of both 3 and 5, print "FizzBuzz".

Example Answer

Here is pseudocode for one solution to the problem:

for (i in 1 to 100) {
    if (i mod 15) {
        print("FizzBuzz")
    } else if (i mod 5) {
        print("Buzz")
    } else if (i mod 3) {
        print("Fizz")
    } else {
        print(i)
    }
}

The program iterates through the numbers 1 to 100. For each iteration, it first checks whether the number is divisible by 15, and if so, it prints “FizzBuzz”. If not, it checks whether the number is divisible by 5 and, if so, prints “Buzz”. If not, it checks ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Build a Career in Data Science

Build a Career in Data Science

Emily Robinson, Jacqueline Nolis
Build a Career in Data Science video edition

Build a Career in Data Science video edition

Emily Robinson, Jacqueline Nolis
Learning Data Science

Learning Data Science

Sam Lau, Joseph Gonzalez, Deborah Nolan
Data Science for Business

Data Science for Business

Foster Provost, Tom Fawcett

Publisher Resources

ISBN: 9781617296246Publisher SupportOtherPublisher WebsiteErrata PagePurchase Link