when using regular expressions, which of the following expressions uses a reserved character that can represent any single character?
Muhammad
Guys, ada yang tau jawabannya?
dapatkan when using regular expressions, which of the following expressions uses a reserved character that can represent any single character? dari situs web ini.
py4e/quiz_chapter11.md at master · AmaniAbbas/py4e · GitHub
Python for Everybody Specialization - University of Michigan - Coursera - py4e/quiz_chapter11.md at master · AmaniAbbas/py4e
master
py4e/Course-3/Quizzes/quiz_chapter11.md
AmaniAbbas Add Course 3
1 contributor108 lines (80 sloc) 3.17 KB
** 1- Which of the following best describes "Regular Expressions"?**
1) A small programming language unto itself
2) A way to solve Algebra formulas for the unknown value
3) The way Python handles and recovers from errors that would otherwise cause a traceback
4) A way to calculate mathematical values paying attention to operator precedence
Answer is 1) A small programming language unto itself
** 2- Which of the following is the way we match the "start of a line" in a regular expression?**
1) ^ 2) str.startswith() 3) \linestart
4) String.startsWith()
5) variable[0:1] Answer is 1) ^
** 3- What would the following mean in a regular expression? [a-z0-9]**
1) Match any number of lowercase letters followed by any number of digits
2) Match a lowercase letter or a digit
3) Match an entire line as long as it is lowercase letters or digits
4) Match any text that is surrounded by square braces
5) Match anything but a lowercase letter or digit
Answer is 2) Match a lowercase letter or a digit
** 4- What is the type of the return value of the re.findall() method?
1) A list of strings
2) An integer 3) A boolean
4) A single character
5) A string
Answer is 1) A list of strings
** 5- What is the "wild card" character in a regular expression (i.e., the character that matches any character)?**
1) . 2) * 3) $ 4) ^ 5) + 6) ? Answer is 1) .
** 6- What is the difference between the "+" and "*" character in regular expressions?**
1) The "+" matches at least one character and the "*" matches zero or more characters
2) The "+" matches upper case characters and the "*" matches lowercase characters
3) The "+" matches the beginning of a line and the "*" matches the end of a line
4) The "+" matches the actual plus character and the "*" matches any character
5) The "+" indicates "start of extraction" and the "*" indicates the "end of extraction"
Answer is 1) The "+" matches at least one character and the "*" matches zero or more characters
** 7- What does the "[0-9]+" match in a regular expression?**
1) Several digits followed by a plus sign
2) Any number of digits at the beginning of a line
3) Any mathematical expression
4) Zero or more digits
5) One or more digits
Answer is 5) One or more digits
** 8- What does the following Python sequence print out?**
x = 'From: Using the : character'
y = re.findall('^F.+:', x)
print(y) 1) : 2) ^F.+: 4) ['From:'] 5) From:
6) ['From: Using the :']
Answer is 6) ['From: Using the :']
** 9- What character do you add to the "+" or "*" to indicate that the match is to be done in a non-greedy manner?**
1) \g 2) ** 3) ++ 4) $ 5) ? 6) ^ Answer is 5) ?
** 10- Given the following line of text:**
From [email protected] Sat Jan 5 09:14:16 2008
What would the regular expression '\[email protected]\S+' match?1) [email protected] 2) \@\ 3) From 4) [email protected]
Answer is 5) [email protected]
Week 3 Practice Quiz: Regular Expressions
Question 1- hen using regular expressions, which of the following expressions uses a reserved character that can represent any single character?
Week 3 Practice Quiz: Regular Expressions
Home TopicsWeek 3 Practice Quiz: Regular Expressions
Home › Forums › Assignment courserra › Google IT in Automation with Python Professional Certificate › Using Python to interact with the operating system › Week 3 Practice Quiz: Regular Expressions
Tagged: Coursera, Crash Course, Google, Google IT Automation, Python, Using Python to Interact with the Operating System
This topic has 0 replies, 1 voice, and was last updated 2 years, 6 months ago by Abhishek Tyagi.
Viewing 0 reply threads
Author Posts
August 27, 2020 at 9:58 pm
#1229 Abhishek Tyagi Keymaster
Question 1- hen using regular expressions, which of the following expressions uses a reserved character that can represent any single character?
Answer-
re.findall(f.n, text)The dot (.) represents any single character.
Question 2- Which of the following is NOT a function of the Python regex module?
Answer-
re.grep()Question 3- The circumflex [^] and the dollar sign [$] are anchor characters. What do these anchor characters do in regex?
Answer-
Match the start and end of a lineQuestion 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?
Answer-
Special CharactersQuestion 5- What is grep?
Answer-
A command-line regex toolThis topic was modified 2 years, 6 months ago by Abhishek Tyagi.
Author Posts
Viewing 0 reply threads
You must be logged in to reply to this topic.
login
login Forums
Assignment courserra
Assignment NPTEL_ Cody Bank CS 50
Recent Posts
Example code for Siamese Neural Network
Siamese Neural Network
Word-2-Vec Natural Language Processing (NLP)
TF – IDF Natural Language Processing (NLP)
Bag of Words (BoW) Algorithm NLP
Categories
ALGORITHMS COURSES PROGRAMS
sumber : roboticswithpython.com
WEEK 3:: PYTHON AUTOMATION REGEX(REGULAR EXPRESSION) Flashcards
PRACTICE QUIZ Learn with flashcards, games, and more — for free.
WEEK 3:: PYTHON AUTOMATION REGEX(REGULAR EXPRESSION)
4.8 (9 reviews) Term 1 / 28
When using regular expressions, which of the following expressions uses a reserved character that can represent any single character?
Click the card to flip 👆
Definition 1 / 28
re.findall(f.n, text)
(The dot (.) represents any single character.)
Click the card to flip 👆
Created by dojikerze PRACTICE QUIZ
Terms in this set (28)
When using regular expressions, which of the following expressions uses a reserved character that can represent any single character?
re.findall(f.n, text)
(The dot (.) represents any single character.)
Which of the following is NOT a function of the Python regex module?
re.grep()
(The grep command utilizes regular expressions on Linux, but is not a part of the standard re Python module.)
The circumflex [^] and the dollar sign [$] are anchor characters. What do these anchor characters do in regex?
Match the start and the end of a line
(the circumflex and the dollar sign specifically match the start and end of a line.)
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.
(Special characters, sometimes called meta characters, give special meaning to the regular expression search syntax.)
What is grep?
A command line regex tool
(The grep command is used to scan files for a string of characters occurring that fits a specified sequence.)
Which of the following demonstrates how regex (regular expressions) might be used?
Find strings of text that match a pattern
(Regex is a search query that matches the regular expression pattern you've specified.)
Rather than using the index() function of the string module, we can use regular expressions, which are more flexible. After importing the regular expression module re, what regex function might be used instead of standard methods?
re.search()
(Using the re module provides more robust solutions, not limited to just re.search().)
Using the terminal, which of the following commands will correctly use grep to find the words "sling" and "sting" (assuming they are in our file, file.txt)?
[email protected]:~$ grep s.ing /usr/file.txt
(In regex, a dot is a wildcard, so it can represent any character. This command will print both "sting" and "sling", if they are in the file.)
Fill in the code to check if the text passed contains the vowels a, e and i, with exactly one occurrence of any other character in between.
import re
def check_aei (text):
result = re.search(r"a.e.i", text)
return result != None
print(check_aei("academia")) # True
print(check_aei("aerial")) # False
print(check_aei("paramedic")) # True
Fill in the code to check if the text passed contains punctuation symbols: commas, periods, colons, semicolons, question marks, and exclamation points.
import re
def check_punctuation (text):
result = re.search(r"[,.:;?!]", text)
return result != None
--------------------
print(check_punctuation("This is a sentence that ends with a period.")) # True
print(check_punctuation("This is a sentence fragment without a period")) # False
print(check_punctuation("Aren't regular expressions awesome?")) # True
print(check_punctuation("Wow! We're really picking up some steam now!")) # True
print(check_punctuation("End of the line")) # False
Sign up and see the remaining cards. It’s free!
By signing up, you accept Quizlet's
Terms of Service and Privacy Policy
Continue with Google
Continue with Facebook
Students also viewed
Practice quiz: before version control
5 terms ymmiffy
Coursera (Practice Quiz: Branching & Merging)
5 terms kirito553933
Coursera (Practice Quiz: Understanding the Pr…
5 terms kirito553933
Practice quiz: version control systems
5 terms ymmiffy
Recent flashcard sets
Lecture 20: eukaryotic pathogens and vectors
25 terms emilyfisher222 NSC final 103 terms eli250201 Art et pouvoir 69 terms Maya_Br
Sets found in the same folder
WEEK 2:: PYTHON AUTOMATION MODIFY FILE DIRECT…
19 terms dojikerze
WEEK 4 PYTHON AUTOMATION
23 terms dojikerze
WEEK 5 PYTHON AUTOMATION SOFTWARE TESTING
22 terms dojikerze
CHAPTER2 AUTOMATION::USING PYTHON TO INTERACT…
20 terms dojikerze
Other sets by this creator
AUTOMATED PYTHON WEEK 3 WORKING WITH REGULAR…
2 terms dojikerze WEEK 1:: G SUITE 3 terms dojikerze
WEEK1 :: CLOUD ENG. GCP STORAGE OPTION, CONTA…
10 terms dojikerze
WEEK 1:: CLOUD ENG - IAM ROLES
8 terms dojikerze
Verified questions
Chemistry
What is the molarity of 90.0 g of
NH_4 Cl NH 4 ​
Cl in 2.25 L aqueous solution?
Verified answer Physics
Waves don't overlap in the image of a pinhole camera. Does this feature contribute to a sharp image or to a blurry image?
Guys, ada yang tau jawabannya?