Write 10 multiple-choice questions that would test a reader\'s comprehension of
ID: 3676971 • Letter: W
Question
Write 10 multiple-choice questions that would test a reader's comprehension of Perl regular expressions. As your “answer”, you must create (10 times) a STRING (to bind a regular expression to), a regular expression PATTERN (to bind to the string), and 4 multiple-choice answers (of which, only one is correct and three are only slightly off from the correct answer). As an example, consider the following code:
For the following question, choose the substring that will be printed.
my $string = "STRING";
if ($string =~ /PATTERN/) { print "[$&]"; }
else { print "undef "; }
A. CORRECT SUBSTRING C. INCORRECT SUBSTRING
B. INCORRECT SUBSTRING D. INCORRECT SUBSTRING
In each case, you should creatively create incorrect substrings that would be the correct answer if the reader interpreted the regex pattern incorrectly. This means that your answers might not look similar (because slightly differing Regex patterns might yield very different answers).
While you are not required to write out the Perl code, your answers would go into the aforementioned problem in a manner similar to the following:
my $string = "This is a statement that is about to be bound to a regular
expression pattern in the Perl script! ";
if ($string =~ /s(t).w/) { print "[$&]"; }
else { print "undef "; }
A. [ state] C. undef
B. [state] D. [the]
In the previous example, the correct answer is B and answers A and C were chosen as strings that might match if someone misinterpreted the meaning of one or some of the characters in the regular expression pattern. When choosing incorrect answers, consider simple facts that people often overlook when learning REGEX. For example, people tend to forget that .* at the end of a pattern will match the remainder of the string and forget to include it in the match region after they have decided a match has occurred. Another example is .* at the beginning of a pattern - people tend to realize that .* tends to push the rest of the pattern match to as far into the string as possible (i.e., to match a second or later match in the string); after deciding a match has occurred, some people forget to include .* in their assessment of what the match region is.
What to submit:
Your answers should each include 4 items: the string to test, the REGEX pattern to bind to the string, the correct answer, and the 4 choices (one of which is the correct one). You do not need to put your information into a Perl script like the examples above.
Example to submit (10 of the following).
Question 01:
String: "This is a statement that is about to be bound to a regular expression
pattern in a Perl script! "
Pattern: /s(w).w/
Answer: B
Choices:
A: [is is]
B: [state]
C: [that]
D: [ound to]
Explanation / Answer
Question 01:
String: "You have to grow from the inside out. None can teach you, none can make you spiritual. There is no other teacher but your own soul.! "
Pattern: /^s[w]+[u][w]+l$/
Answer: B
Choices:
A: [soul]
B: [spiritual]
C: [you]
D: [out]
Question 02:
String: " We are what our thoughts have made us; so take care about what you think. Words are secondary. Thoughts live; they travel far.! "
Pattern: /^t[w]+k$/
Answer: D
Choices:
A: [Thoughts]
B: [thoughts]
C: [take]
D: [think]
Question 03:
String: " The world is the great gymnasium where we come to make ourselves strong.! "
Pattern: /^w[w]+e$/
Answer: C
Choices:
A: [world]
B: [we]
C: [where]
D: [make]
Question 04:
String: " You cannot believe in God until you believe in yourself.! "
Pattern: /[you][w]+l$/
Answer: C
Choices:
A: [You]
B: [you]
C: [until]
D: [yourself]
Question 05:
String: " Condemn none: if you can stretch out a helping hand, do so. If you cannot, fold your hands, bless your brothers, and let them go their own way.! "
Pattern: /[w]?(and)?s$/
Answer: D
Choices:
A: [and]
B: [hand]
C: [helping]
D: [hands]
Question 06:
String: " truth can be stated in a thousand different ways, yet each one can be true.! "
Pattern: /T[w]+s[cd][w]+sbe$/
Answer: C
Choices:
A: [one can be]
B: [thousand different]
C: [truth can be]
D: [thousand]
Question 07:
String: " Arise,awake and donot stop until the goal is reached.! "
Pattern: /a[^Arw]/
Answer: C
Choices:
A: [goal]
B: [Arise]
C: [and]
D: [awake]
Question 08:
String: " Where can we go to find god if we cannot see Him in our own hearts and in every living being! "
Pattern: /[w]*(go)[w]+/
Answer: B
Choices:
A: [go]
B: [god]
C: [god if]
D: [find god]
Question 09:
String: " The more we come out and do good to others, the more our hearts will be purified, and God will be in them. "
Pattern: /[w]+r[it](fi|ea)/
Answer: C
Choices:
A: [more we]
B: [be purified]
C: [purified]
D: [hearts]
Question 10:
String: " All differences in this world are of degree, and not of kind, because oneness is the secret of everything.! "
Pattern: /[w]+(r)[w]*ee$/
Answer: B
Choices:
A: [differences]
B: [degree]
C: [oneness]
D: [of degree]
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.