Python Built-ins u0026 Libraries: Quick Concepts Quiz Quiz

  1. Regular Expressions: Pattern Matching

    What function from the 're' module would you use to check if a string starts with 'Hello'?

    1. re.scan
    2. re.compare
    3. re.check
    4. re.find
    5. re.match
  2. Datetime: Getting Current Date

    Which function from the 'datetime' module returns the current local date and time as a datetime object?

    1. datetime.now
    2. datetime.time
    3. datetime.today
    4. datetime.current
    5. datetime.local
  3. OS: Listing Directory Contents

    Which function from the 'os' module can be used to list all files and folders in a directory?

    1. os.listdir
    2. os.list
    3. os.dirs
    4. os.walkdir
    5. os.folders
  4. Collections: Counter Usage

    If you want to count the number of occurrences of each element in a list, which class from 'collections' would you use?

    1. Counter
    2. Accumulator
    3. Tally
    4. Frequency
    5. CountMap
  5. Itertools: Repeating Elements

    Which function from the 'itertools' module would you use to endlessly repeat the element 10?

    1. itertools.infinite
    2. itertools.copy
    3. itertools.repeat
    4. itertools.cycle
    5. itertools.loop
  6. Sys: Exiting a Program

    How do you immediately exit a Python program using the 'sys' module?

    1. sys.stop()
    2. sys.quit()
    3. sys.exit()
    4. sys.break()
    5. sys.end()
  7. RE: Extracting with Groups

    Which method would you use to extract all matching groups from a string using a compiled regex pattern?

    1. findgroup
    2. extractall
    3. findgroups
    4. scan
    5. findall
  8. Datetime: Formatting Dates

    What method would you use to format a datetime object as a custom string (e.g., '2024-06-10')?

    1. as_string
    2. strftime
    3. tostring
    4. convert
    5. format
  9. OS: Changing Working Directory

    Which function sets the current working directory to a new path in the 'os' module?

    1. os.cddir
    2. os.chdir
    3. os.setcwd
    4. os.cd
    5. os.setdir
  10. Collections: NamedTuple Purpose

    Which collections class allows you to create immutable record-like objects with named fields?

    1. recordtuple
    2. datatuple
    3. namedtuple
    4. valuetuple
    5. fieldtuple
  11. Itertools: Cartesian Product

    Which itertools function generates the cartesian product between two lists?

    1. itertools.merge
    2. itertools.join
    3. itertools.chain
    4. itertools.product
    5. itertools.combine
  12. Sys: Accessing Command-line Arguments

    Which attribute of the 'sys' module contains the list of command-line arguments passed to a script?

    1. sys.parameters
    2. sys.argv
    3. sys.cmd
    4. sys.args
    5. sys.input
  13. RE: Replace Substrings

    Which 're' module function replaces all occurrences of a pattern in a string with a replacement string?

    1. re.replace
    2. re.sub
    3. re.change
    4. re.switch
    5. re.swap
  14. Collections: Default Value Dictionaries

    Which 'collections' class creates a dictionary that provides a default value for missing keys?

    1. smartrdict
    2. initdict
    3. defaultdict
    4. autodict
    5. defaultdictory
  15. Itertools: Infinite Counting Sequence

    Which itertools function produces infinite numbers starting from a specific value, such as 5, 6, 7, ...?

    1. itertools.grow
    2. itertools.step
    3. itertools.progress
    4. itertools.count
    5. itertools.increase