Difference between revisions of "CSC111 Final Exam 2015"

From dftwiki3
Jump to: navigation, search
Line 103: Line 103:
 
=Problem 3: Twitter=
 
=Problem 3: Twitter=
 
<br />
 
<br />
* Click on this URL: http://cs.smith.edu/dftwiki/media/twitterFeed.txt and save the text that will display in your browser to a text file that you will call twitterFeed.txt, in a directory of your choice on your computer.  Do not edit the information in the file, and do not remove anything from it, as your program will be tested with another file, similar in format, but with different content.
+
* Write a program called '''final3.py''' that asks the user for 3 pieces of information:
 +
::# the name of a file that contains tweets from or to @smithcollege
 +
::# a location of interest
 +
::# a keyword of interest
 +
* The program then reads a file containing tweets, and outputs several pieces of information:
 +
::# the date and time of the earliest tweet stored in the file
 +
::# the date and time of the most recent tweet stored in the file
 +
::# the number of tweets whose location contains the ''location of interest'' entered by the user
 +
::# the number of tweets whose text contains the keyword of interest.
 
<br />
 
<br />
 +
==Format of the File==
 
<br />
 
<br />
 +
* The file provided to you, and which will be used to test your program, are illustrated by this simple example.
 +
 +
----
 +
Date: Fri Mar 27 12:22:58 +0000 2015
 +
Text: #smithieslead MT @GlobalTiesUS:  1st female @afsatweets officer! Grad of @smithcollege
 +
Screen name: smithcollege
 +
Location: Northampton, MA
 +
 +
* Explanations:
 +
:* A tweet is always preceded by a line of 4 dashes.
 +
:* The second line is the date the tweet was created.  You can discard the "+0000" field, which refers to a time zone.
 +
:* The third line contains the name of the sender or repeater.  Most of the tweets come from  "@smithcollege".
 +
:* The fourth line contains the location associated with the tweet.
 +
 
<br />
 
<br />
 +
==Sample File==
 +
* Click on this URL: http://cs.smith.edu/dftwiki/media/twitterFeed.txt and save the text that will display in your browser to a text file that you will call '''twitterFeed.txt''', in a directory of your choice on your computer.  Do not edit the information in the file, and do not remove anything from it, as your program will be tested with another file, similar in format, but with different content.
 +
<br />
 +
==Example Interaction with the User==
 +
<br />
 +
* Below is an example of an interaction with the solution program:
 +
<br />
 +
File name? twitterFeeeeeeeed.txt
 +
Invalid file name.  Please reenter
 +
File name? twit.txt
 +
Invalid file name.  Please reenter
 +
File name? twitterFeed.txt
 +
Location of interest? Northampton
 +
keyword of interest? Maya
 +
---Output---
 +
283 tweets read
 +
earliest:  20150326 15:12:09
 +
latest:    20150422 14:13:57 
 +
Number of distinct locations =  34
 +
Number of times Northampton appears=  215
 +
Number of times Maya appears in text=  4
 +
 
 +
<br />
 +
* Your program must match this output as closely as possible.  Remember that your program will be tested with a collection of tweets that will be different, and probably gathered in a different time period.
 +
 
<br />
 
<br />
 
<br />
 
<br />

Revision as of 17:27, 22 April 2015


...