讲解:CS 105、Python、Python、IDLE edi
CS 105 – Intro to Computing Non-Tech Spring 2019Page 1 of 3MP 7 – Extra CreditIn this MP, you will create 3 simple functions in one module. It is VERY important you name the moduleand the functions exactly as you are instructed. If the names are not correct, you will get no credit.1. The ModuleRecall that in Python, all code in a single .py file (the sort that the IDLE editor saves) is called a module.The NAME of the module is the bit before the ‘.py’. Therefore, a module named factorial would becontained in a file named factorial.py. For this python MP, please name your module _mp7. Mynetid is aharris, therefore, my module name would be aharris_mp7 and the file name would beaharris_mp7.py. You will turn in that single file using the standard hand-in site. Note: There can be NOspaces or non-alphanumeric characters other than the underscore (‘_’) in the module name.2. General InstructionsThese general instructions will be the same for each Python lab/MP. You will turn in a source file with yourfunctions in it. For this assignment, while you should use test cases, prior to turn in, you will comment outeach test case. Recall, in Python, comments are any line that starts with a ‘#’. For example, consider thefollowing code:def func(a): return aprint(func(‘Bob’))This code snippet has one function, the function has one line (the return). The code also has one test case.If you run this code in it, it will print ‘Bob’. To comment out the test case, you simply place a ‘#’ in front ofthe test case line, so the code looks like the following:def func(a): return a#print(func(‘Bob’))Now if you run the code, it will load the function in memory, but print nothing.CS 105 – Intro to Computing Non-Tech Spring 2019Page 2 of 3So, before you turn in your code, comment out all your test cases, but NOT your functions. If you commentout functions, you will not get credit for those functions (because as far as the interpreter is concerned, theydon’t exist). The grading script will remove any print and input statements not commented out and this maybreak your code and result in a 0.Testing: Remember when testing your function, don’t just test using the single example test case providedto you. Try to think of possible cases that will cause your function to break! For example, if the function issupposed to take a single string as input, test it with a string containing spaces, punctuation,CS 105作业代做、代写Python实验作业、Python程序语言作业调试、代做IDLE editor作业 帮做Has etc. If thefunction calculates an equation, pass in zero or negative numbers, or big numbers. If your function containsloops or conditionals, test all edge cases of the conditionals and loops. The grading script will use betweenfive and ten test cases. You will not be given the test cases we choose prior to grading. It is part of yourassignment to come up with comprehensive testing. For the first few assignments, this will not be difficult.3. Function One: countDownSpecificationThe first function you will write should be called ‘countDown’. Your function should take zero (0)arguments.The function should return one (1) list containing integers from 10 to 1 and finally, the string “Liftoff!”. (i.e.,[10, 9, 8, 7, 6, 5, 4, 3, 2, 1, ‘Liftoff!’]).You function must be recursive (i.e., it should contain a call to itself within the function body). You will getNO credit if you use any loops (for, while, etc).4. Function Two: myLSearchSpecification:Assume you are given a sorted list of integers to search. Your job is to write a search algorithm to find theindex of a particular number.CS 105 – Intro to Computing Non-Tech Spring 2019Page 3 of 3The second function you will write should be called ‘myLSearch’. Your function should take two (2)arguments: an integer to search for and a sorted list of integers.The function should return one (1) integer, the index in the input list containing the input integer. If theinput integer does not exist in the list, your function should return -1.For credit, you MUST use either a for or a while loop. This search algorithm should NOT be recursive.There should be no call to itself in the body of the function or you will get no credit.5. Function Three: myRSearchSpecification:Assume you are given a sorted list of integers to search. Your job is to write a search algorithm to find theindex of a particular number.The third function you will write should be called ‘myRSearch’. Your function should take two (2)arguments: an integer to search for and a sorted list of integers.The function should return one (1) integer, the index in the input list containing the input integer. If theinput integer does not exist in the list, your function should return -1.For credit, you MUST NOT use either a for or a while loop. This search algorithm MUST be recursive.There should be at least one call to itself in the body of the function or you will get no credit.转自:http://www.7daixie.com/2019050556937198.html