Difference between revisions of "CSC111 Midterm Exam Preparation 2015"
Line 172: | Line 172: | ||
=Question 17= | =Question 17= | ||
<br /> | <br /> | ||
− | Assume that we have | + | Assume that we have strings that containing several words, including a phone number. All the strings are known to contain a phone number. The area code of the phone number is made of 3 digits, and is always included in parentheses. There are never spaces between the parentheses and the digits. There is only 1 open-parenthesis in the strings. |
− | The area code of the phone number is made of 3 digits, and is always included in parentheses. There are never spaces between the parentheses and the digits. | + | |
+ | Below is an example of a string containing such a pattern. | ||
<br /> | <br /> | ||
::<source lang="text"> | ::<source lang="text"> | ||
Line 179: | Line 180: | ||
</source> | </source> | ||
<br /> | <br /> | ||
− | Write the python code necessary to extract the area code and store it in a variable called <tt>areaCode</tt>. The contents of the variable will be just 3 digits. For the string shown above, the variable <tt>areaCode</tt> | + | Write the python code necessary to extract the area code and store it in a variable called <tt>areaCode</tt>. The contents of the variable will be just 3 digits. For the string shown above, the variable <tt>areaCode</tt> would be assigned "413" by your code. |
<br /> | <br /> | ||
</onlydft> | </onlydft> |
Revision as of 08:00, 1 March 2015
--D. Thiebaut (talk) 18:08, 28 February 2015 (EST)
Midterm Exam Prep
The midterm is an in-class exam given under the rules of the honor code. It lasts 70 minutes. It will be closed books, closed notes, closed computers. The questions below will give you a taste for the type of questions you will find in the exam. Work on each question on paper, possibly interacting with people around you if you get stuck. You can find the answers different ways: a) by going to the special lab session dedicated to the midterm preparation, b) by reading the text book, c) by using Idle and writing up a solution, and/or d) by reviewing the lectures notes for each week.