講解:COMP1405A、Python、Computer Science I、PythonProcessing|

COMP1405A (Fall 2018)Introduction to Computer Science ISpecification for Assignment 5 of 6Your submission for this assignment must include your full name (as it appears on cuLearn)and you nine-digit student number as a comment at the top of every source file you submit.Your submission for this assignment must be a single source file with a file name ofcomp1405_f18_#########_a5.py (with the number signs replaced by your nine-digitstudent number). It must also be written using the Python 3 programming language, andmust run on the official virtual machine.Do NOT compress your submission into a zip file.Late assignments will not be accepted and will receive a mark of 0.Submissions that crash (i.e., terminate with an error) on execution will receive a mark of 0.The due date for this assignment is Saturday, November 17, 2018, by 11:00pm.For this assignment, you will create a program that allows users to work with cryptograms.Your program must be completely organized into a collection of functions described bythis document, and your program is not permitted to use any global variables whatsoever.To accomplish this, you will need to pass elements of data back and forth betweenfunctions using arguments and return values. COMP1405A (Fall 2018) ? Introduction to Computer Science ISpecification for Assignment 5 of 6You must start with a main function that takes no arguments and produces no returnvalues. Additionally, as the very last line of your program, you must call this main function.You will notice that this function is preceded by a multi-line comment that has been wrappedin triple single quotation marks. You are required to write a comment like this for eachof the functions you create for this assignment. This comment must begin with a shortdescription of what the function does, contain a list (labeled @params) of indented itemscorresponding to the parameter variables you use to hold your function arguments, andcontain a description of any return values (labeled @return). If the function you are writinghas no params or returns, then you must still include the @params or @return tag and write(and indent) the word none.Failure to observe this requirement will result in a penalty.Much of your program will be written into the function definition of that main function. Thisfunction is expected to provide a basic interface to the user. Your user should be able to usethe menu to select an option and your program will call the corresponding function(and input if necessary). This will allow your user to load/save files and generate customalphabets for encryption or decryption.Every time your user sees the main menu you must display for them:a) the initial unmodified text last loaded by the load function (initially empty)b) the current text that your program most recently created by enciphering ordecipheringc) a list of options from which the user will select their next step, including at leastsaving a file, loading a file, defining an alphabet, enciphering, and deciphering.Please note that in order for you to be able to complete all of the functions specified on thefollowing page, your main function must have at least three variables, for storing 1) theinitial unmodified text, 2) the current text being modified by the user, and 3) thecurrent alphabet being used for enciphering and deciphering.A flowchart explaining some of the functionality expected is COMP1405A作業(yè)代做、代寫Python程序作業(yè)、代做Computer Science I作業(yè)、代寫Python編程included on the following page.COMP1405A (Fall 2018) ? Introduction to Computer Science ISpecification for Assignment 5 of 6You must write a function for loading data. It must receive one string argument andproduce one string return value. The argument will be the name of the file to be loaded andthe return value will be the entire body of text contained in the file. This function must notcrash if the user specifies an invalid filename (i.e., you must handle this exception) andmust, instead, return an empty string.You must write a function for saving data. It must receive two string arguments andproduce no return value. The arguments will be the name of the file to be saved and the textto be saved in the file, respectively.You must write a function for enciphering data. It must receive two string argumentsand produce one string return value. The first argument will be the text to be enciphered,and the second argument will the be alphabet to be used for this enciphering. The returnvalue will be the enciphered text. Consider the following example for clarification:You must write a function for deciphering data. It must receive two string argumentsand produce one string return value. The first argument will be the text to be deciphered,and the second argument will the be alphabet to be used for this deciphering. The returnvalue will be the deciphered text. Consider the following example for clarification:COMP1405A (Fall 2018) ? Introduction to Computer Science ISpecification for Assignment 5 of 6You must write a function called cryptogram_alphabet. It must receive no argumentsand produce one string return value. This function will use input to ask the user to type analphabet (i.e., type the 26 letters of the English alphabet in any order). If the argumentcontains all 26 letters then the argument, converted to uppercase if necessary, then it is thereturn value. If, on the other hand, the input does not contain all 26 letters or containsduplicate letters, you will print an error message and return the unmodified alphabetABCDEFGHIJKLMNOPQRSTUVWXYZ.Your solution must not import any libraries, but you are free to use any of the followingfunctions from the standard library: list, range, upper, str, input, open, read, close, ord,chr, print, len, and also int, insert, append, and pop.Your program must not use any of the string processing functions. This includes, but isnot limited to, find/rfind, index/rindex, replace, sort, strip, split, translate or the built-inencode or decode functions. If you want to use these functions then you will need towrite them yourself from scratch.Your solution may use the indexing operator (i.e., you can use a[x] to get the element of alist or string that is located at index x) but your solution must not use the slicing operator(i.e., you cannot use a[x:y] to access the elements of the list or string that have indicesbetween x and y-1).Your solution must not use list comprehensions in any way.Your solution must not use dictionaries or maps in any way either.This program (along with any other program submitted in this class) must be a completelyoriginal work, authored by you and you alone, prepared for this offering (i.e., Fall 2018) ofCOMP1405. Do not discuss this assignment with anyone except the instructor or the teachingassistants, and do not copy images or source code samples from the internet or any othersource.轉(zhuǎn)自:http://ass.3daixie.com/2018111948272590.html

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • By clicking to agree to this Schedule 2, which is hereby ...
    qaz0622閱讀 1,639評論 0 2
  • pyspark.sql模塊 模塊上下文 Spark SQL和DataFrames的重要類: pyspark.sql...
    mpro閱讀 9,920評論 0 13
  • 文 / 不懂時間的鐘 最近,被能量條鬧的,簡圈和朋友圈傻傻分不清。 點了一天的贊,我的能量條只剩下50%的能量,于...
    不懂時間的鐘閱讀 335評論 4 10
  • 最近看了好多書和文章,看到腦袋都開始發(fā)懵、變得混沌??炊嗔司蜁ニ伎?,然后有一些或沉重或無奈的想法。果然,人類一思...
    John小姐閱讀 571評論 0 0
  • 來生要做一棵樹,一半在塵土里安詳,一半在風(fēng)里飛揚,一半灑落陰涼,一半沐浴陽光?!墩f給自己聽》 三毛是我喜歡...
    蒹穗閱讀 567評論 0 1

友情鏈接更多精彩內(nèi)容