🌍 freeCodeCamp · flashcards

freeCodeCamp Scientific Computing with Python Flashcards

50 question-and-answer cards covering Scientific Computing with Python as it is examined in freeCodeCamp. 24 of them are printed below, taken from across the deck — no signup, no paywall on the preview.

50Cards in deck
24Free preview
19Syllabus topics
~309Chars per answer
FreePrice

24 sample cards from the Scientific Computing with Python deck

Sampled from the end of the deck, so these are different cards from the ones shown on the syllabus page.

  1. What is 'duck typing' in Python?

    A style of polymorphism where an object's suitability is determined by the methods and attributes it actually has, not its declared type: 'if it walks like a duck and quacks like a duck, it's a duck.' Code calls obj.quack() without checking isinstance; any object providing quack() works.

  2. Why is the with statement the preferred way to open files in Python?

    with open('file.txt') as f: creates a context manager that automatically closes the file when the block exits — even if an exception occurs — preventing resource leaks. Without it you must remember to call f.close() manually in a finally block.

  3. What do the file modes 'r', 'w', 'a', and 'r+' mean in Python's open()?

    'r' = read only (error if the file doesn't exist); 'w' = write, truncating/overwriting any existing content (creates the file if absent); 'a' = append, writing at the end while preserving existing content; 'r+' = read and write without truncating. Add 'b' for binary mode, e.g. 'rb'.

  4. Compare the file-reading methods read(), readline(), and readlines().

    read() returns the entire file as one string; readline() returns the next single line (including its trailing newline); readlines() returns a list of all lines. For large files, iterating directly with 'for line in f:' is most memory-efficient because it streams line by line.

  5. What is the difference between 'import math' and 'from math import sqrt'?

    import math binds the whole module; you access members with the prefix, e.g. math.sqrt(16) computes $\sqrt{16} = 4$. from math import sqrt imports only that name into the current namespace so you call sqrt(16) directly. 'import module as alias' (e.g. import numpy as np) gives a shorthand name.

  6. What does the idiom if __name__ == '__main__': accomplish in a Python file?

    Code under it runs only when the file is executed directly as a script, not when the file is imported as a module. When imported, __name__ equals the module's name; when run directly, __name__ equals the string '__main__'. It lets a file serve as both a reusable module and a runnable program.

  7. In what order does Python search for a module when you write an import statement?

    Python searches sys.path in order: 1) the directory containing the running script (or current directory), 2) directories in the PYTHONPATH environment variable, 3) the standard library, and 4) installed third-party packages in site-packages. The first match wins.

  8. In Python regular expressions, what do the metacharacters \d, \w, \s, ., ^, and $ match?

    \d matches a digit 0–9; \w matches a 'word' character (letter, digit, or underscore); \s matches whitespace; . matches any character except newline; ^ anchors the match to the start of the string; $ anchors it to the end. Capitalized versions (\D, \W, \S) match the complement.

  9. In regex, what do the quantifiers *, +, ?, and {m,n} mean?

    * = zero or more repetitions; + = one or more; ? = zero or one (optional); {m,n} = between m and n repetitions inclusive. By default quantifiers are greedy (match as much as possible); appending ? (e.g. *?) makes them lazy/non-greedy.

  10. Compare the re module functions re.search(), re.match(), and re.findall().

    re.search(pattern, s) scans the whole string and returns a Match object for the first occurrence (or None); re.match() only matches at the beginning of the string; re.findall() returns a list of all non-overlapping matches (or of captured groups if the pattern has groups).

  11. What is a REST API, and which HTTP methods correspond to the four CRUD operations?

    A REST API is a web interface where clients access resources at URLs using standard HTTP methods. CRUD mapping: Create → POST, Read → GET, Update → PUT (or PATCH for partial updates), Delete → DELETE. Responses typically carry data as JSON.

  12. Using Python's requests library, how do you fetch JSON from an API and check for success?

    response = requests.get(url); check response.status_code == 200 (or call response.raise_for_status() to raise on errors); then data = response.json() parses the JSON body into Python dicts/lists. Query parameters are passed with the params= keyword argument.

  13. What do the HTTP status code ranges 2xx, 4xx, and 5xx indicate? Give one key example of each.

    2xx = success (200 OK, 201 Created); 4xx = client error — the request was wrong (400 Bad Request, 401 Unauthorized, 404 Not Found, 429 Too Many Requests); 5xx = server error — the server failed (500 Internal Server Error, 503 Service Unavailable).

  14. What sequence of steps does a Python program follow to run a query against an SQLite database with the sqlite3 module?

    1) conn = sqlite3.connect('file.db') opens/creates the database; 2) cur = conn.cursor() gets a cursor; 3) cur.execute(sql, params) runs the SQL; 4) fetch results with cur.fetchone()/fetchall(); 5) conn.commit() saves any changes (INSERT/UPDATE/DELETE); 6) conn.close() closes the connection.

  15. Why should you use parameterized queries like cur.execute('SELECT * FROM users WHERE name = ?', (name,)) instead of string formatting in SQL?

    Placeholders (?) let the database driver safely escape user input, preventing SQL injection attacks where malicious input alters the query's structure. Building SQL with f-strings or concatenation embeds raw user text directly into the command and is a critical security flaw.

  16. What makes SQLite different from client-server databases like MySQL or PostgreSQL?

    SQLite is serverless and embedded: the entire database lives in a single file on disk and the library runs inside your application process — no separate server, no network, no user accounts. It ships in Python's standard library (sqlite3), making it ideal for local apps and prototyping, but it handles concurrent writers poorly compared to server databases.

  17. In the freeCodeCamp Arithmetic Formatter project, what five error conditions must arithmetic_arranger reject, and with which messages?

    1) More than 5 problems → 'Error: Too many problems.'; 2) an operator other than + or - (e.g. * or /) → "Error: Operator must be '+' or '-'."; 3) non-digit characters in an operand → 'Error: Numbers must only contain digits.'; 4) an operand longer than 4 digits → 'Error: Numbers cannot be more than four digits.' Only + and - are supported; multiplication/division are invalid.

  18. How is each problem laid out in the Arithmetic Formatter's vertical output?

    Right-align both operands; the width of each problem is the length of the longer operand plus 2 (one for the operator, one for the space after it). The operator sits on the left of the second line, dashes span the full problem width, problems are separated by exactly 4 spaces, and answers appear on a bottom line only if show_answers is True.

  19. In the freeCodeCamp Time Calculator, what are the inputs and required output forms of add_time()?

    Inputs: a 12-hour start time like '3:00 PM', a duration like '3:10' (hours:minutes), and an optional starting day of the week. Output stays in 12-hour format with AM/PM and appends nothing if the result is the same day, '(next day)' if it lands 1 day later, or '(n days later)' for $n \geq 2$. If a day was given, the result includes the new capitalized day name, e.g. '6:10 PM, Monday (20 days later)'.

  20. What arithmetic converts a 12-hour time plus a duration into the final time and days elapsed (Time Calculator logic)?

    Convert start to minutes past midnight (add $12 \times 60$ for PM, treat 12 AM as 0); add the duration in minutes. Days elapsed $= \left\lfloor \frac{\text{total minutes}}{1440} \right\rfloor$; remaining time $= \text{total} \bmod 1440$. Then hour $= \left\lfloor \frac{\text{remaining}}{60} \right\rfloor$, minute $= \text{remaining} \bmod 60$, and convert back to 12-hour AM/PM. New weekday index $= (\text{start index} + \text{days}) \bmod 7$.

  21. In the freeCodeCamp Budget App, what do the Category methods deposit(), withdraw(), transfer(), and check_funds() do?

    deposit(amount, description) appends {'amount': amount, 'description': description} to the ledger. withdraw() appends a negative amount only if check_funds passes, returning True/False. transfer(amount, other) withdraws with description 'Transfer to [Dest]' and deposits into the other category as 'Transfer from [Source]', returning True/False. check_funds(amount) returns True only if amount does not exceed the current balance (sum of ledger amounts).

  22. How is a Category's string output formatted in the Budget App?

    A title line of exactly 30 characters with the category name centered in asterisks; then one line per ledger item: the first 23 characters of the description, then the amount right-aligned with 2 decimal places in 7 characters (line total 30); finally a line 'Total: x.xx'. Example: '*************Food*************'.

  23. In the freeCodeCamp Polygon Area Calculator, what formulas does the Rectangle class use for area, perimeter, and diagonal?

    For width $w$ and height $h$: area $= w \times h$, perimeter $= 2w + 2h$, and diagonal $= \sqrt{w^{2} + h^{2}}$. get_amount_inside(other) returns how many times another shape fits without rotation: $\left\lfloor \frac{w}{w'} \right\rfloor \times \left\lfloor \frac{h}{h'} \right\rfloor$.

  24. How does the Square class relate to Rectangle in the Polygon Area Calculator project, and what constraint must set_side enforce?

    Square is a subclass of Rectangle whose constructor calls the parent with width = height = side, so it inherits get_area, get_perimeter, get_diagonal, etc. Its set_side(s) method must update both width and height to s (and setting width or height on a Square updates both), keeping the invariant $w = h$. Its string form is 'Square(side=s)' instead of 'Rectangle(width=w, height=h)'.

What this deck covers

The Scientific Computing with Python deck follows the freeCodeCamp Scientific Computing with Python syllabus — 6 chapters and 19 topics — so questions land on material that is genuinely examinable rather than trivia around it. That works out to roughly 8.3 cards per chapter.

Answers are written to be recallable, not just readable — averaging about 309 characters, which is long enough to carry the reasoning and short enough to say out loud.

A deck like this earns its keep on the second and third pass. Read the syllabus first so you know the shape of the subject, then use the cards to find the specific facts that have not stuck.

Scientific Computing with Python flashcards FAQ

How many Scientific Computing with Python flashcards are in this freeCodeCamp deck?

50 cards. This page previews 24 of them, sampled evenly across the deck so you can judge the difficulty before installing anything.

Are these freeCodeCamp flashcards free?

Yes. The preview here is free to read with no signup, and the full 50-card deck is free inside the Examius app.

What do the Scientific Computing with Python cards cover?

They follow the freeCodeCamp Scientific Computing with Python syllabus — 6 chapters and 19 topics — so the questions track what is actually examinable.

How should I use these flashcards?

Read the syllabus first so you know the shape of the subject, then drill the deck. Examius schedules each card with spaced repetition, so cards you keep missing come back sooner and ones you know drift further apart.