Professional Documents
Culture Documents
2. Magic 8 Ball
Am I dating myself by saying I loved Magic 8 Balls as a kid? Well, if you no longer have yours (maybe
because, like me, you smashed it to see what that murky liquid was inside), you can recreate the 8 Ball
logic with this classic Python script example(opens in a new tab)!
This script prints the numbers 1-100, but for multiples of 3 prints “Fizz” instead of the number and for
multiples of 5 prints “buzz.”
In addition to these Python programming examples, there are many other mathematical problems you
can solve using Python. You can use Python to work with complex numbers, factorials, floating point
numbers, lambdas, Fibonacci sequences, data types, and other numeric bits and bobs. Feel free to test
the import math function, play with the range function, and experiment with indexing.
If you love data science, download an IDE and play around with NumPy. There are so many cool ways
that you can explore Python, so we encourage you to try them all.