Questions

  1. What is a regular expression in Python?
  2. Write a Python program to check that a string contains only a certain set of characters (in this case, a–z, A–Z, and 0–9).
  3. Which module in Python supports regular expressions?
    a) re
    b) regex
    c) pyregex
    d) None of the above
  4. What does the re.match function do?
    a) Matches a pattern at the start of the string
    b) Matches a pattern at any position in the string
    c) Such a function does not exist
    d) None of the above
  5. What is the output of the following?
    Sentence: "we are humans"
    Matched: re.match(r'(.*) (.*?) (.*)', sentence)
    print(matched.group())

a) ('we', 'are', 'humans')
b) (we, are, humans)
c) ('we', 'humans')
d) 'we are humans'

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset