Menu
CoddyTech
Course

Python for C Developers

Move from C to Python: compare pointers and object references, integer arithmetic, containers, functions, and classes. Practice in multi-file tasks and build an order processor with interchangeable pricing policies.

C and Python side by side

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

  1. Printing Without Format Codes

    C printf interprets a format string and requires argument types that match its conversions. Python print accepts objects, converts them to text, separates multiple arguments with spaces, and ends with a newline by default. Python single and double quotes both…

    C
    1#include <stdio.h>2#include <stdlib.h>3#include <string.h>4#include <stdarg.h>5int main(void) {6    printf("%s %d\n", "Count:", 3);7    return 0;8}
    Python
    1print("Count:", 3)
  2. Absence Is Not a Null Pointer

    C NULL is a null pointer constant used in pointer contexts; it is not an ordinary missing integer value. Python None is a singleton object representing absence and can be bound to any name. Use is None to test it. True and False are Python boolean objects and…

    C
    1#include <stdio.h>2#include <stdlib.h>3#include <string.h>4#include <stdarg.h>5int main(void) {6    int *p = NULL;7    printf("%d %d\n", p == NULL, 4 > 2);8    return 0;9}
    Python
    1p = None2print(p is None, 4 > 2)
  3. Lists Versus C Arrays

    A C array has a fixed number of contiguous elements of one type. A Python list is a growable sequence of object references, and its elements need not share a type. Indexes start at zero; a negative Python index counts from the end. A slice excludes its stop…

    C
    1#include <stdio.h>2#include <stdlib.h>3#include <string.h>4#include <stdarg.h>5int main(void) {6    int values[] = {4, 8, 12};7    printf("%d\n", values[2]);8    return 0;9}
    Python
    1values = [4, 8]2values.append(12)3print(values[-1])4print(values[:2])
  4. Iteration Without Pointers

    Python for visits values from an iterable. It has no C-style three-clause header or increment operator. range(start, stop) produces integers up to but excluding stop, so an inclusive ascending interval requires stop + 1. With the default positive step, a…

    C
    1#include <stdio.h>2#include <stdlib.h>3#include <string.h>4#include <stdarg.h>5int main(void) {6    for (int i = 2; i < 5; ++i) printf("%d\n", i);7    return 0;8}
    Python
    1for i in range(2, 5):2    print(i)
  5. Functions and Object Arguments

    C functions receive parameter values; copying a pointer still allows access to the pointed-to object. Python calls bind parameter names to the supplied objects. Rebinding an integer parameter does not rebind the caller name, but mutating a supplied list is…

    C
    1#include <stdio.h>2#include <stdlib.h>3#include <string.h>4#include <stdarg.h>5int twice(int value) { value *= 2; return value; }6int main(void) {7    int x = 3; int y = twice(x);8    printf("%d %d\n", x, y);9    return 0;10}
    Python
    1def twice(value):2    value *= 23    return value4x = 35print(x, twice(x))
  6. Text Input and Exact Output

    C fgets keeps a newline when one fits in its buffer, while Python input removes the line terminator and returns a string. Convert numeric text explicitly. strip removes surrounding whitespace but preserves internal spaces; apply it only where the contract…

    C
    1#include <stdio.h>2#include <stdlib.h>3#include <string.h>4#include <stdarg.h>5int main(void) {6    int cents = 507;7    printf("fee: %d.%02d\n", cents / 100, cents % 100);8    return 0;9}
    Python
    1cents = 5072print(f"fee: {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 Programs to Python, Values and Truth Tests, Containers and Aliasing, 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