What comes next

Introduction

You have finished the Python track. You can now read and write programs with variables, conditions, loops, functions, recursion, lists, dictionaries, sets, classes and exceptions, and you have met the first data structures and algorithms of computer science.

You have come a long way from your first print. The core ideas you have learned, values, decisions, repetition, functions and data structures, exist in nearly every programming language, so the next language will be far easier to learn.

How it works

What you have learned

AreaLessons
Basicsvariables, operators, input, formatting, conditions, loops
Datastrings, lists, tuples, sets, dictionaries, comprehensions, text processing
Functionsparameters, scope, recursion, generators, functions as values, memoization
Reliable codeexceptions, raising errors, testing, debugging
Objectsclasses, inheritance, special methods
Data structures and algorithmsstacks, queues, linked lists, trees, complexity, searching, sorting, two pointers

Where to go next

  • Practice: work through every practice problem you have not solved yet; the dashboard shows what is left.
  • Data Structures and Algorithms: the next course in the CSE curriculum builds directly on the last part of this track.
  • Structured Programming in C: the same ideas with memory you manage yourself; the visualizer will show pointers as arrows.
  • Build something: a quiz game, a budget tracker, or a timetable helper. Small, real projects teach the most.

Syntax

for n in range(1, 16):
    if n % 15 == 0:
        print("FizzBuzz")
    elif n % 3 == 0:
        print("Fizz")

Example

for n in range(1, 16):
    if n % 15 == 0:
        print("FizzBuzz")
    elif n % 3 == 0:
        print("Fizz")
    elif n % 5 == 0:
        print("Buzz")
    else:
        print(n)
Open in compiler

FizzBuzz prints the numbers 1 to 15, but "Fizz" for multiples of 3, "Buzz" for multiples of 5 and "FizzBuzz" for both. It is a famous first interview question. The key detail is the order of the checks: n % 15 == 0 must come first, or 15 would print "Fizz". Step through and watch which branch each number takes.

Line by line

  1. for n in range(1, 16): counts from 1 to 15.
  2. n % 15 == 0 is tested first, because 15 also divides by 3 and by 5.
  3. The next two tests handle multiples of 3 and of 5.
  4. else handles every other number by printing it.

Expected result

1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz

In the real world

FizzBuzz is famous as a first interview question because it tests careful thinking about order. After this course, you could take on small automation scripts, data analysis or web back ends.

Common mistakes

  • Moving on from a topic without writing any code of your own.
  • Reading solutions before you have tried to solve the problem.
  • Trying to learn several new technologies at the same time.

Best practices

  • Build small projects that you actually want to use.
  • Read error messages and documentation before searching for answers.
  • Keep your projects, because together they become a portfolio.

Summary

You have covered the core of Python and the first ideas of computer science. Practising on your own problems is what turns this knowledge into skill, and the next course can build directly on it.

Practice

Change FizzBuzz to run to 100 and also print "Bang" for multiples of 7 (and combine words when several apply, such as "FizzBang" for 21).

Quick check

1. Why must n % 15 == 0 be checked first in FizzBuzz?
2. Which structure gives O(1) lookup by key?
3. What is the best way to keep improving?

Key takeaways

  • You now know the core of programming, which carries over to every language.
  • Real skill comes from building and debugging your own programs.
  • Choose your next course according to what you want to build.

Practice problems for this lesson

My notes

Write down what you want to remember from this lesson. Notes are saved on this device as you type, and appear on your dashboard.