LOGBOOK

HELP

Quiz Entry - updated: 2026.07.14

What are the key syntactic differences between Python and C?

C makes you write down everything Python infers for you: explicit types, semicolons to end statements, braces for blocks, and your own memory management.

# Python
def binary_search(data, N, value):
    lo, hi = 0, N-1
    while lo < hi:
        mid = (lo + hi) // 2
        if data[mid] < value:
            lo = mid + 1
        else:
            hi = mid
    return lo if data[lo] == value else -1
// C
int binary_search(int *data, int N, int value) {
    int lo = 0, hi = N-1;
    while (lo < hi) {
        size_t mid = (lo + hi) / 2;
        if (data[mid] < value)
            lo = mid + 1;
        else
            hi = mid;
    }
    return (hi == lo && data[lo] == value) ? lo : -1;
}

Key differences:

Aspect Python C
Types Dynamic, implicit Static, explicit
Blocks Indentation Braces { }
Statements Newline ends Semicolon ; required
Memory Garbage collected Manual management
Arrays Dynamic, bounds-checked Fixed size, no checking

From Quiz: REVE1 / C Programming | Updated: Jul 14, 2026