辅导program编程、Python语言程序调试、Python编程设计辅导 讲解Database|讲解数据库SQL
- 首页 >> Python编程 load
Load a file of movie titles. Prompt for the name of a file. If no name is
input (e.g. if using input() and the user presses the enter key), load from
"movies.txt", otherwise load it from the specified filename.
The file of movie titles is a text file is formatted with one movie per
line.
random Randomly pick a movie title and display it.
search
Prompt for a string, and then search for and display all movies that contain
this string Search case-independently, and separate the movies with a blank
line. If the search string is empty, exit the search and redisplay the menu.
Once this is going, modify search to prompt for two strings. If you enter an
empty string when prompted for the second string, it just searches for a
single string, as before, but if the second string is non-empty, it only displays
movies that contain both strings.
starts
with
Prompt for a string and then search for and display all movies that start with
this string. Search case-independently, and separate movies with a blank
line. If the search string is empty, exit the starts with search and redisplay the
menu.
keep Add the last displayed movie to a list of your favourites.
favourites Display the current favourites list.
clear Clear the favourites list.
quit Quit the program.
Assignment 2: A Movie Title Explorer
There's a file of the top 1000 or so movie titles called movies.txt. For this question you're to build
a way of displaying a random movie title, finding movies, and building and saving a list of movies
you would like to watch.
The program first displays a menu (something like that shown below) and carries out the
appropriate action depending on which letter the user types, and then redisplays the menu:
You should have a function for each of the commands below, except for Quit.
The valid commands are:
*** Movie Title Explorer ***
l – load file of movie titles
r – random movie
s – search
sw – starts with
k – keep - save the last displayed movie title to your favourites
f – favourites display
c – clear favourites
q – quit
command:
Don't forget to add appropriate checks. e.g. to make sure the file of movies has been loaded.
IMPORTANT: make sure that you use functions. Many of the commands could be in hteir own
function.
What and how to submit How:
What: Submit your Python program, each named with.py extension.
Do not submit Word documents (.doc or .docx) or .zip files.
Check that:
all programs should display your name,ID number and your classname when starting.
that your files have a .py extension
Load a file of movie titles. Prompt for the name of a file. If no name is
input (e.g. if using input() and the user presses the enter key), load from
"movies.txt", otherwise load it from the specified filename.
The file of movie titles is a text file is formatted with one movie per
line.
random Randomly pick a movie title and display it.
search
Prompt for a string, and then search for and display all movies that contain
this string Search case-independently, and separate the movies with a blank
line. If the search string is empty, exit the search and redisplay the menu.
Once this is going, modify search to prompt for two strings. If you enter an
empty string when prompted for the second string, it just searches for a
single string, as before, but if the second string is non-empty, it only displays
movies that contain both strings.
starts
with
Prompt for a string and then search for and display all movies that start with
this string. Search case-independently, and separate movies with a blank
line. If the search string is empty, exit the starts with search and redisplay the
menu.
keep Add the last displayed movie to a list of your favourites.
favourites Display the current favourites list.
clear Clear the favourites list.
quit Quit the program.
Assignment 2: A Movie Title Explorer
There's a file of the top 1000 or so movie titles called movies.txt. For this question you're to build
a way of displaying a random movie title, finding movies, and building and saving a list of movies
you would like to watch.
The program first displays a menu (something like that shown below) and carries out the
appropriate action depending on which letter the user types, and then redisplays the menu:
You should have a function for each of the commands below, except for Quit.
The valid commands are:
*** Movie Title Explorer ***
l – load file of movie titles
r – random movie
s – search
sw – starts with
k – keep - save the last displayed movie title to your favourites
f – favourites display
c – clear favourites
q – quit
command:
Don't forget to add appropriate checks. e.g. to make sure the file of movies has been loaded.
IMPORTANT: make sure that you use functions. Many of the commands could be in hteir own
function.
What and how to submit How:
What: Submit your Python program, each named with.py extension.
Do not submit Word documents (.doc or .docx) or .zip files.
Check that:
all programs should display your name,ID number and your classname when starting.
that your files have a .py extension