08 | Assignment 08
560 "Working with Files" Portfolio Sample
We started coding this in class. We did not finish. If you need the screen shots to code this up they are in this pdf:
This is a major project. It has elements from the following sessions:
- Python Basics ✅
- Decision Structures ✅
- Repetition Structures ✅
- Functions 1 ✅
- Functions 2
- Lists & Tuples
- Dictionaries
- Files and Exceptions ✅
This project requires collecting several CSV lists. The lists are then presented to the user as choices in a dropdown list.
Here is an example dropdown list based on one student's files:
What file would you like to search for?:
a) 60s-music file
b) athletes file
x) to exit
If the user chooses "a", then the output reads as follows:
Enter the search term for 60s-music.csv file:
If the user searched for beatles
then the following output would be printed:
Your search term Beatles exists in the 60s-music.csv file!
Would you like to see the entries? (y or n)?
If the user entered Y or y, then the following would be returned:
Here are all of the entries with the term Beatles:
Hey Jude,The Beatles
I Want to Hold Your Hand,The Beatles
Yesterday,The Beatles
A Day in the Life,The Beatles
Let It Be,The Beatles
Help!,The Beatles
Twist and Shout,The Beatles
I Want to Hold Your Hand,The Beatles
All You Need Is Love,The Beatles
Strawberry Fields Forever,The Beatles
Notice that there is a repition in the file. This is because ChatGPT is not very good at creating a list of items without repetition.
Therefore part of this project may require that you copy your list into excel and do a sort and remove duplicates.
This in-class exercise demonstrates familiarity with
import
- specifically
import sys
while
loopwhile True:
input()
'''triple quote string'''
if:
- variables
=
assignment operator==
equals comparison operatorsys.exit()
elif:
else:
continue
- input with variable
.title()
method- f-strings
- function with arguments (
def
) - global and local scope variables
with
open
/as
- working with
.csv
files - '
r
' read - file.
read()
if
/in
for
line
in
fileline.strip()
- call function
- git and GitHub