← All PCAP Flashcard Decks

File I/O and String Operations Flashcards

6 cards from real PCAP practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.

Read the first 6 File I/O and String Operations flashcards as text
  1. What does the `'b'` flag in `open('file', 'rb')` indicate?

    Answer: Binary mode

    The `'b'` flag opens the file in binary mode, reading/writing raw bytes instead of text.

  2. Which method replaces occurrences of a substring in a string?

    Answer: replace()

    `str.replace(old, new)` returns a new string with all occurrences of `old` replaced by `new`.

  3. What does `str.find('x')` return if 'x' is not in the string?

    Answer: -1

    `str.find()` returns `-1` when the substring is not found, unlike `index()` which raises `ValueError`.

  4. Which string method counts non-overlapping occurrences of a substring?

    Answer: count()

    `str.count(sub)` returns the number of non-overlapping occurrences of the substring.

  5. What does `os.path.join('folder', 'file.txt')` return on Linux?

    Answer: folder/file.txt

    `os.path.join()` combines path components using the OS-appropriate separator (`/` on Unix/Linux).

  6. Which encoding is the default for text files opened with `open()` in Python 3?

    Answer: UTF-8 on most systems (locale-dependent)

    Python 3 uses the platform's default encoding (typically UTF-8) unless explicitly specified.

How this page was made: written with AI tools and published by Nathan Beja, founder of Practice Test Geeks, who is responsible for its content. Exam facts are checked against the official sources listed below. Not reviewed by a subject-matter expert. Editorial policy

Sources & references

Exam facts on this page (fees, format, dates, passing scores) are checked against these official sources; the date is our last check. Editorial policy

  1. pythoninstitute.org — Eligibility, fees, exam format, passing score, retake fee, retake policy, score release, time limit, score validity, exam information · verified Oct 2026
  2. home.pearsonvue.com — Test delivery · verified Oct 2026