Data Science Questions and Answers – Regular Expressions and Text Variables

This set of Data Science Multiple Choice Questions & Answers (MCQs) focuses on “Regular Expressions and Text Variables”.

1. Which of the following function is good for the automatic splitting of names?
a) split
b) strsplit
c) autsplit
d) none of the mentioned
View Answer

Answer: b
Explanation: strsplit split a character string or vector of character strings using a regular expression or a literal string.

2. Point out the correct statement.
a) gsub is used for fixing character vectors
b) sub is used for finding values like grep
c) grep is used for fixing character vectors
d) none of the mentioned
View Answer

Answer: a
Explanation: sub and gsub is used for fixing character vectors.

3. Which of the following function is used for fixing character vectors?
a) tolower
b) toUPPER
c) toLOWER
d) all of the mentioned
View Answer

Answer: a
Explanation: It translates character to lowercase.

4. Which of the following metacharacter is used to refer to any character?
a) %
b) @
c) .
d) All of the mentioned
View Answer

Answer: c
Explanation: A dot in function name can mean any of the following: nothing at all; a separator between method and class in S3 method.

advertisement
advertisement

5. Point out the wrong statement.
a) Variables with character values should be made less descriptive
b) Variables with character values should usually be made into factor variable
c) Common variables are used to apply transforms
d) All of the mentioned
View Answer

Answer: a
Explanation: Variables with character values should be made more descriptive.

6. Which of the following is used for specifying character class with metacharacter?
a) []
b) {}
c) /+
d) All of the mentioned
View Answer

Answer: a
Explanation: You can list set of characters to accept a given point in the match.

7. Regular expressions can be thought of as a combination of literals and metacharacters.
a) True
b) False
View Answer

Answer: a
Explanation: Regular expressions have rich set of metacharacters.

8. Which of the following signs are used to indicate repetition?
a) #
b) *
c) –
d) All of the mentioned
View Answer

Answer: b
Explanation: * and + are metacharacters for repetition of data.

advertisement

9. Which of the following function is used for searching text strings by means of regular expression?
a) grepd
b) grepl
c) gepexpr
d) all of the mentioned
View Answer

Answer: b
Explanation: grep, grepl, regexpr, gregexpr and regexec search for matches to argument pattern within each element of a character vector.

10. merge function is used for merging data frames.
a) True
b) False
View Answer

Answer: a
Explanation: To merge two data frames horizontally, use the merge function.

advertisement

Sanfoundry Global Education & Learning Series – Data Science.

Here’s the list of Best Books in Data Science.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.