Week 3 – Regular Expressions

using python to interact with the operating system week 3 answers

Practice Quiz: Regular Expressions

1. When using regular expressions, which of the following expressions uses a reserved character that can represent any single character?

  • re.findall(fu$, text)
  • re.findall(f*n, text)
  • re.findall(^un, text)
  • re.findall(f.n, text)

2. Which of the following is NOT a function of the Python regex module?

  • re.grep()
  • re.match()
  • re.search()
  • re.findall()

3. The circumflex [^] and the dollar sign [$] are anchor characters. What do these anchor characters do in regex?

  • Match the start and end of a word.
  • Match the start and end of a line
  • Exclude everything between two anchor characters
  • Represent any number and any letter character, respectively

4. When using regex, some characters represent particular types of characters. Some examples are the dollar sign, the circumflex, and the dot wildcard. What are these characters collectively known as?

  • Special characters
  • Anchor characters
  • Literal characters
  • Wildcard characters

5. What is grep?

  • An operating system
  • A command for parsing strings in Python
  • A command-line regex tool
  • A type of special character

Devendra Kumar

Project Management Apprentice at Google

Leave a Reply