โ† All POC Flashcard Decks

Automation & Scripting Flashcards

7 cards from real POC practice questions. Tap to flip, then mark Knew It or Still Learning โ€” missed cards come back until you master them.

Read the first 7 Automation & Scripting flashcards as text
  1. Which Python library is most commonly used to automate interactions with Excel spreadsheets without needing Microsoft Office installed?

    Answer: openpyxl

    `openpyxl` reads and writes `.xlsx` files natively in pure Python, supporting formulas, charts, and cell styles without Office.

  2. In Python, what is the safest way to delete a directory tree including all its contents?

    Answer: shutil.rmtree(path)

    `shutil.rmtree()` recursively removes a directory and all its contents; `os.rmdir()` only works on empty directories.

  3. Which approach correctly retries a failing network request up to 3 times in a Python automation script?

    Answer: Using a `for` loop with `try/except` and `break` on success

    A `for _ in range(3): try: ... break except: ...` loop is the standard pattern; `requests` itself has no built-in retry, but `urllib3.Retry` + `HTTPAdapter` can add it to a Session.

  4. What does `glob.glob('**/*.py', recursive=True)` return?

    Answer: All `.py` files in the current directory and all subdirectories

    With `recursive=True`, the `**` pattern matches zero or more directory levels, so all `.py` files in the tree are returned as a list of strings.

  5. In Python's `smtplib`, which sequence correctly sends an email using a Gmail SMTP server with TLS?

    Answer: smtplib.SMTP('smtp.gmail.com', 587) then smtp.starttls() then smtp.login() then smtp.sendmail()

    Port 587 with `starttls()` upgrades the plaintext connection to TLS before credentials are sent; port 465 uses `SMTP_SSL` for implicit TLS from the start.

  6. Which `multiprocessing` class provides a shared dictionary that can be safely accessed from multiple worker processes?

    Answer: multiprocessing.Manager().dict()

    `Manager().dict()` creates a proxy dict backed by a manager server process, making it safe for concurrent access across processes.

  7. When automating PDF generation in Python, which library renders HTML/CSS to PDF without requiring a browser binary?

    Answer: WeasyPrint

    WeasyPrint converts HTML+CSS to PDF using its own rendering engine; `pdfkit` requires `wkhtmltopdf`, and `fpdf` builds PDFs programmatically without HTML.