🌍 CS50x: Introduction to Computer Science · subject

CS50x: Introduction to Computer Science Python Syllabus

Every chapter and topic of Python examined in CS50x: Introduction to Computer Science — 4 chapters, 13 topics, plus 50 flashcards written against it.

4Chapters
13Topics
0Sub-topics
~10hEst. first pass
12%Of CS50x: Introduction to Computer Science
50Flashcards

Python syllabus — full chapter and topic list

Expand any chapter to see its topics and sub-topics. This is the whole examinable outline for Python in CS50x: Introduction to Computer Science, not a summary of it.

  1. Python Fundamentals

    4 topics
    • Functions, Arguments, and Return Values
    • Variables and Data Types
    • Conditionals and Boolean Expressions
    • Loops
  2. Modules and Libraries

    3 topics
    • Modules and Packages
    • The Standard Library
    • Third-Party Libraries with pip
  3. Data and I/O

    3 topics
    • Lists, Tuples, Dictionaries, and Sets
    • File I/O
    • Exceptions
  4. Advanced Python

    3 topics
    • Regular Expressions
    • Object-Oriented Programming
    • Truthiness and Comprehensions

Python flashcards for CS50x: Introduction to Computer Science

25 of 50 cards from the Python deck — real questions with worked answers.

  1. In Python, what keyword defines a function, and what is the basic syntax?

    The `def` keyword defines a function: `def name(parameters):` followed by an indented block. Example: `def square(x): return x * x`.

  2. What is the difference between a parameter and an argument in Python?

    A parameter is the variable named in the function definition (e.g., `x` in `def f(x):`); an argument is the actual value passed when the function is called (e.g., `f(5)` passes the argument 5).

  3. What does a Python function return if it has no `return` statement (or a bare `return`)?

    It returns `None`, Python's special object representing the absence of a value.

  4. What is the difference between positional arguments, keyword arguments, and default parameter values in Python?

    Positional arguments are matched to parameters by order; keyword arguments are matched by name (e.g., `f(x=3)`); default values in the definition (e.g., `def f(x, n=2):`) make a parameter optional.

  5. Name the four primitive built-in data types in Python for numbers, text, and truth values, with an example of each.

    `int` (whole numbers, e.g., 42), `float` (decimals, e.g., 3.14), `str` (text, e.g., "hello"), and `bool` (`True` or `False`).

  6. Is Python statically or dynamically typed, and what does that mean for variables?

    Dynamically typed: a variable's type is determined by the value currently assigned at runtime, no type declaration is needed, and the same name can later be bound to a value of a different type.

  7. In Python, what do the operators `/`, `//`, `%`, and `**` compute?

    `/` is true division (always returns a float), `//` is floor division (e.g., 7 // 2 = 3, i.e., $\lfloor \frac{7}{2} \rfloor$), `%` is the modulo/remainder (7 % 2 = 1), and `**` is exponentiation (e.g., 2 ** 3 computes $2^{3} = 8$).

  8. How do you convert a string to an integer in Python, and why is this needed for user input?

    Use `int(s)`, e.g., `n = int(input("Number: "))`. It is needed because `input()` always returns a string, so arithmetic requires explicit conversion (casting) with `int()` or `float()`.

  9. What is the difference between `=` and `==` in Python?

    `=` is the assignment operator (binds a value to a variable); `==` is the equality comparison operator (evaluates to `True` or `False`).

  10. Write the general structure of an if/elif/else block in Python and state how many branches execute.

    `if condition:` ... `elif other_condition:` ... `else:` ... — exactly one branch executes: the first condition that is true, or the `else` block if none are.

  11. What are Python's three logical (Boolean) operators, and how do they differ from other languages' symbols?

    `and`, `or`, and `not` — Python uses English words instead of `&&`, `||`, and `!`.

  12. What does short-circuit evaluation mean for `and` and `or` in Python?

    `x and y` stops and returns `x` if `x` is falsy (y is never evaluated); `x or y` stops and returns `x` if `x` is truthy. Evaluation halts as soon as the result is determined.

  13. What is the difference between a `while` loop and a `for` loop in Python?

    A `while` loop repeats as long as a condition remains true (unknown number of iterations); a `for` loop iterates over each item of an iterable (e.g., `for x in range(5):`), typically for a known sequence of items.

  14. What sequence does `range(n)` produce, and what do `range(a, b)` and `range(a, b, s)` produce?

    `range(n)` yields 0, 1, ..., n-1. `range(a, b)` yields a up to b-1 (end exclusive). `range(a, b, s)` yields a, a+s, a+2s, ... while still less than b (step s).

  15. What do `break` and `continue` do inside a Python loop?

    `break` exits the loop entirely and immediately; `continue` skips the rest of the current iteration and jumps to the next iteration.

  16. How do you write an intentional infinite loop in Python, and how is it typically exited?

    `while True:` creates an infinite loop; it is exited with `break` when some condition is met (a common pattern for validating user input).

  17. What is the difference between a module and a package in Python?

    A module is a single `.py` file containing Python definitions; a package is a directory of modules (traditionally containing an `__init__.py` file) that groups related modules under one namespace.

  18. Contrast `import module` with `from module import name` in Python.

    `import csv` binds the module object, so you access members as `csv.reader`; `from csv import reader` imports the name directly into the current namespace, so you call `reader` without the module prefix.

  19. What does the idiom `if __name__ == "__main__":` do in a Python file?

    It runs the guarded code only when the file is executed directly as a script; when the file is imported as a module, `__name__` equals the module's name instead of "__main__", so the block is skipped.

  20. What is the Python standard library, and why is Python described as coming with "batteries included"?

    It is the large collection of modules (e.g., `math`, `random`, `csv`, `re`, `sys`, `os`) shipped with every Python installation, so common tasks can be done without installing anything — hence "batteries included".

  21. Name the standard library functions for picking a random item from a list and a random integer in a range.

    `random.choice(seq)` returns a random element of a sequence; `random.randint(a, b)` returns a random integer $n$ with $a \leq n \leq b$ (both endpoints inclusive).

  22. In Python's `sys` module, what are `sys.argv` and `sys.exit()` used for?

    `sys.argv` is the list of command-line arguments (with `sys.argv[0]` being the program's name); `sys.exit(code)` terminates the program, conventionally with exit status 0 for success and nonzero for error.

  23. What is pip, and what command installs a third-party package with it?

    pip is Python's package installer, which downloads packages from PyPI (the Python Package Index); `pip install package_name` installs a package (e.g., `pip install requests`).

  24. How does a third-party Python library differ from a standard library module?

    Standard library modules ship with Python and can be imported immediately; third-party libraries are written by others, hosted on PyPI, and must be installed (e.g., with pip) before they can be imported.

  25. What is a requirements.txt file used for in a Python project?

    It lists the project's third-party dependencies (one package per line, optionally with versions) so they can all be installed at once with `pip install -r requirements.txt`.

See more Python flashcards →

Planning Python for CS50x: Introduction to Computer Science

Python is about 12% of the CS50x: Introduction to Computer Science syllabus by topic count — 13 of 112 topics, spread over 4 chapters. At roughly 45 minutes per topic plus 12 minutes per sub-topic, a first pass runs to about 10 hours.

The heaviest chapters are Python Fundamentals (4 topics), Modules and Libraries (3 topics), Data and I/O (3 topics) . Front-load those while your energy is high; the short chapters are better revision filler later.

Work top-down: read the chapter, then tick topics off individually rather than marking the whole chapter done. Sub-topics are where silent gaps hide.

Python (CS50x: Introduction to Computer Science) FAQ

What is in the CS50x: Introduction to Computer Science Python syllabus?

Python is split into 4 chapters — Python Fundamentals, Modules and Libraries, Data and I/O and Advanced Python, containing 13 topics and 0 sub-topics in total.

How is Python structured in the CS50x: Introduction to Computer Science syllabus?

4 chapters. Python accounts for about 12% of the topics in the whole CS50x: Introduction to Computer Science syllabus (13 of 112).

How long should I spend on Python for CS50x: Introduction to Computer Science?

Budget around 10 hours for a first pass through Python — about 45 minutes per topic plus 12 minutes per sub-topic across its 13 topics. Add revision cycles on top.

Are there flashcards for CS50x: Introduction to Computer Science Python?

Yes — a 50-card Python deck. Sample cards are printed on this page, and the full deck is free in the Examius app with spaced repetition scheduling.