联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp2

您当前位置:首页 >> Python编程Python编程

日期:2021-03-01 11:02

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


版权所有:留学生编程辅导网 2018 All Rights Reserved 联系方式:QQ:99515681 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。