Menu
CoddyTech
Course

Python for C++ Developers

Transfer C++ experience to Python: compare value semantics, STL containers, functions, RAII and context managers, and runtime object behavior. Build an order processor across four connected multi-file steps.

C++ and Python side by side

The same program in C++ and in Python, from the lessons of this course.

  1. Streams to print

    Python runs statements at module level without an int main wrapper. C++ stream insertion chains values with <<; Python print accepts separate arguments and inserts spaces by default. Both examples print two lines. In Python, single and double quotes both…

    C++
    1std::cout << "Status: ready\n" << "Don't stop\n";
    Python
    1# A comment for readers2print("Status:", "ready")3print("Don't stop")
  2. None, nullptr, and bool

    C++ nullptr is a null pointer value; Python None is an ordinary singleton object representing absence. Python names do not have pointer types to dereference. Test absence with is None. None is distinct from zero and False. Python boolean literals are…

    C++
    1int* seats = nullptr;2std::cout << std::boolalpha << (seats == nullptr) << '\n' << false << '\n';
    Python
    1seats = None2print(seats is None)3available = False4print(available)
  3. From vector to list

    A Python list is a growable ordered container, like vector in many everyday uses, but stores references to objects without a declared element type. Indexes start at zero and negative indexes count from the end. items[:2] copies the outer list up to but…

    C++
    1std::vector<int> items{4, 8};2items.push_back(12);3std::cout << items.back() << '\n';
    Python
    1items = [4, 8]2items.append(12)3print(items[-1])4print(items[:2])
  4. Range Loops and Rebinding

    Python for visits values from an iterable. range(start, stop, step) supplies integers and excludes stop; range(3) visits 0, 1, 2. There is no three-clause C++ for syntax. C++ auto& in a range loop can refer to a container element, so assignment updates that…

    C++
    1std::vector<int> values{2, 4};2for (auto& value : values) value += 1;3std::cout << values[0] << ' ' << values[1] << '\n';
    Python
    1for value in [2, 4]:2    print(value)3for i in range(3):4    print(i)
  5. Functions and Shared Objects

    Define a Python function with def, a parameter list, and a colon. No return type is required. return sends a value to the caller; reaching the end returns None. C++ by-value vector parameters copy the vector, while a Python parameter is a local name bound to…

    C++
    1auto twice = [](int value) { return value * 2; };2std::cout << twice(4) << '\n';
    Python
    1def twice(value):2    return value * 23print(twice(4))
  6. Text Input and Exact Output

    Python input() reads a line without its ending newline and returns str. Unlike formatted C++ stream extraction with >>, it does not parse numbers or stop at internal whitespace. Convert numbers with int and strip surrounding whitespace only when the contract…

    C++
    1std::string label = "Green tea";2int cents = 305;3std::cout << label << ": " << cents / 100 << '.' << std::setw(2) << std::setfill('0') << cents % 100 << '\n';
    Python
    1label = "  Green tea  ".strip()2cents = 3053print(f"{label}: {cents // 100}.{cents % 100:02d}")

Syllabus

10 chapters48 lessons1 project48 challenges99 quiz questions

Apply Your C++ Experience

2 lessons

More courses for C++ developers

Learn Python from another language

Frequently asked questions

Who is Python for C++ Developers for?

For people who already write C++ and want to learn Python. Each lesson starts from C++ you know and shows how Python does the same thing, so you skip the beginner basics.

Do I need to know Python already?

No. The course starts with your first Python program. You need C++ basics: variables, conditions, loops, functions and collections.

How many lessons does Python for C++ Developers have?

Python for C++ Developers contains 48 interactive lessons you can complete at your own pace.

What does Python for C++ Developers cover?

The course is organized into chapters covering: From C++ to Python, Values and Decisions, STL Habits and Python Objects, Iteration and Transformations, and more.

Is Python for C++ Developers free?

Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.

Coddy programming languages illustration

Start Python for C++ Developers for free

Get started