Difference: PythonLab4 (6 vs. 7)

Revision 72019-02-12 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="IntroToCSF2018"

Lab 4- Film Information

Changed:
<
<

Due Oct 16, 11:55

Moodle Link
ft.jpg
Consider the following repl.it: https://repl.it/@JimSkon/FilmViewStart
>
>

Due Feb 26, 11:55

Moodle Link
ft.jpg
Consider the following repl.it: https://repl.it/@JimSkon/FilmViewStart
 
Changed:
<
<
This program includes functions to read through and list the flim titles in a Film file "film.csv". This is a "comma separated values" file, e.g. each value on a line has a comma separating it.
>
>
This program includes functions to read through and list the flim titles in a Film file "film.csv". This is a "comma separated values" file (actully semi-colon separated), e.g. each value on a line has a semi-colon separating it.
 

Goal

Your goal is to fork the repl.it, and create a program for looking up film information.

Step 1

Changed:
<
<
Update the displayFilm(info) so that it displays ALL the information for a given film, and in a nice readable format. Then make a main() function that loops, calling viewByYear() until the user is done.
>
>
Update the displayFilm(info) so that it displays ALL the information for a given film, and in a nice readable format. Then make a main() function that loops, calling viewByYear(filename) to display that entered year's films, until the user is done. The parameter "info" is just a parsed line from the file.
 

Step 2

Changed:
<
<
Using checkFileForString() function from the Emily Dickenson (https://repl.it/@JimSkon/EmilyDickinsonUnique) example write a function createUniqueSubjects() that creates a file subjects.txt which holds all the unique subjects in the film file. You will do this by reading through the film file and looking only at the 4th (offset 3) field. You call checkFileForString() to see if the subject is subjects.txt, and appending it to the file if it is not. You will then need to use the editor to delete the first two subjects (Subject and CAT). If you find a blank subject, remove that also. Once this is done you don't need to call the function anymore, you have the list!

Note - you can skip this step and just manually make the file for a loss of 5 points.

Step 2

Make a function called listBySubjects() that lists the subjects with numbers:

>
>
Make a function called getSubject() that prints the subjects with numbers, and then waits for the users to enter a subject number. Keep asking until they enter a valid subject number. Test this function.
 
1. Comedy
2. Horror
Line: 38 to 32
 14. Romance 15. Fantasy
Deleted:
<
<

 

Step 3

Changed:
<
<
Make a function getSubjectByIndex(subNumber) that, given a subject number, returns the subject string. You will need to read through the first subNumber lines of the file to get to the subject, and return that string. Make sure to call .strip() on the subject to remove the "\n". This will allow you to take a number that user enters, and turn it into subject string.

Note: you can skip this step, and just hard code the subjects for a loss of 5 points.

>
>
Make a function that calls listBySubjects(fileaname). This function should call getSubject(), and then print the matching films using displayFilm(info).
 

Step 4

Changed:
<
<
Make a function that calls getSubjectByIndex(subNumber) to lists the names of the subjects, and then asks for the user to enter a subject number. Then display (nicely formatted) the films with a matching subject field.
>
>
Make a function listByActor() that asks the user to enter an actor number to search for, and then checks BOTH the Actor and Actress fields for a partial or full match, listing all the matching movies. You can use the following code examples to see how to search a string for a string: https://repl.it/@JimSkon/SubstringCheck
 
Changed:
<
<
Make sure your program handles bad inputs appropriately.
>
>
Make sure the matches ignore the capitalization.
 

Step 5

Changed:
<
<
Modify the main() funciton so that it has a loop that asks if the user wants to 1. list by year, 2. list by subject, or 3. end program. Then it calls the appropriate function
>
>
Modify the main() function so that it has a loop that asks if the user wants to 1. list by year, 2. list by subject, 3. List by Actor, or 4. end program. Then it calls the appropriate function from above.
 
Example:
Welcome to the film information program.
Select:
 1. List by year
 2. List by subject
Changed:
<
<
3. exit
>
>
3. List by actor 4. exit
  1
Changed:
<
<
What year do you want to see movies for? 1930 Film: Anna Christie Year: 92 Length: 92 minutes Actor: Bickford, CharlesActress: Garbo, GretaDirectorBrown, ClarenceRating: No%

Film: Romance Year: 76 Length: 76 minutes Actor: Stone, LewisActress: Garbo, GretaDirectorRating: No%

Film: Murder Year: 95 Length: 95 minutes Actor: Marshall, HerbertActress: DirectorHitchcock, AlfredRating: No%

>
>
What year do you want to see movies for? 1925 Film: Joyless Street Year: 1925 Len: 125 min Rating: 73 % Subject: Drama Director: Pabst, Georg Wilhelm Actor: Stuart, Henry Actress: Garbo, Greta
 

Welcome to the film information program. Select: 1. List by year 2. List by subject

Changed:
<
<
3. exit
>
>
3. List by actor 4. exit
  2 1. Comedy 2. Horror
Line: 92 to 81
 13. Crime 14. Romance 15. Fantasy
Changed:
<
<
Pick a subject: 9 Film: Shalako Year: 113 Length: 113 minutes Actor: Connery, SeanActress: Bardot, BrigitteDirectorDmytryk, EdwardRating: No%

Film: Bronco Billy Year: 116 Length: 116 minutes Actor: Eastwood, ClintActress: Locke, SondraDirectorEastwood, ClintRating: No%

Film: A Fistful of Dollars Year: 102 Length: 102 minutes Actor: Eastwood, ClintActress: Volonte, Gian MariaDirectorLeone, SergioRating: No%

>
>
Enter a subject number: 17 1. Comedy 2. Horror 3. Action 4. Drama 5. Mystery 6. Science Fiction 7. Music 8. War 9. Westerns 10. Western 11. Short 12. Adventure 13. Crime 14. Romance 15. Fantasy Enter a subject number: 15 Fantasy Film: Made in Heaven Year: 1987 Len: 102 min Rating: 57% Subject: Fantasy Director: Rudolph, Alan Actor: Hutton, Timothy Actress: McGillis, Kelly
 
Deleted:
<
<
Film: For a Few Dollars More Year: 130 Length: 130 minutes Actor: Eastwood, ClintActress: DirectorLeone, SergioRating: No%
 
Changed:
<
<
Film: Clint Eastwood Collection, The Year: Length: minutes Actor: Eastwood, ClintActress: DirectorRating: No%
>
>
Welcome to the film information program. Select: 1. List by year 2. List by subject 3. List by actor 4. exit 3 What actor do you want to see movies for? cliff Film: Charly Year: 1968 Len: 103 min Rating: 38 % Subject: Drama Director: Nelson, Ralph Actor: Robertson, Cliff Actress: Bloom, Claire

Film: To Die Standing Year: 1991 Len: 87 min Rating: 53 % Subject: Action Director: Morneau, Louis Actor: De Young, Cliff Actress: Rose, Jamie

 
Deleted:
<
<
Film: Good, the Bad & the Ugly, The Year: 163 Length: 163 minutes Actor: Eastwood, ClintActress: DirectorRating: No%
 
Added:
>
>
Welcome to the film information program. Select: 1. List by year 2. List by subject 3. List by actor 4. exit 5
  Welcome to the film information program. Select: 1. List by year 2. List by subject
Changed:
<
<
3. exit 3
>
>
3. List by actor 4. exit
 

Program Design

Changed:
<
<
Below is the expected design in terms of functions. You may have more functions, but you must have at least these:

Screen_Shot_2018-10-01_at_11.11.14_AM.png

>
>
You are to make the functions as specified above. You make make additional helper functions as well.
 
Changed:
<
<
<a href="SDProject1-3?sortcol=0;table=1;up=0#sorted_table" rel="nofollow" title="Sort by this column">Requirement</a>Points<a href="SDProject1-3?sortcol=3;table=1;up=0#sorted_table" rel="nofollow" title="Sort by this column">Comments</a><a href="SDProject1-3?sortcol=4;table=1;up=0#sorted_table" rel="nofollow" title="Sort by this column">Score</a>
Program provides the required function (search by year, search by subject). Also the program uses a file of subjects gleaned from the original text. 40
Code is properly broken up into functions, with one specific task per function. See function hierarchy above. 30
Each function is commented at top of function 10
Program has meaningful comments, good variable names, and good formatting 10
The program has a nice user interface - easy to use. 10
Total
>
>
RequirementPointsCommentsScore
Program provides the required function (search by year, search by subject, search by actor). 40
Code is properly broken up into functions, with one specific task per function. See instructions above. 30
Each function is commented at top of function 10
Program has meaningful comments, good variable names, and good formatting 10
The program has a nice user interface - easy to use. 10
Total
  solution
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback