CS 105 – Intro to Computing Non-Tech Spring 2019

CS 105 – Intro to Computing Non-Tech Spring 2019
Page 1 of 3
MP 7 – Extra Credit
In this MP, you will create 3 simple functions in one module. It is VERY important you name the module
and the functions exactly as you are instructed. If the names are not correct, you will get no credit.
1. The Module
Recall 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 be
contained in a file named factorial.py. For this python MP, please name your module <netid>_mp7. My
netid is aharris, therefore, my module name would be aharris_mp7 and the file name would be
aharris_mp7.py. You will turn in that single file using the standard hand-in site. Note: There can be NO
spaces or non-alphanumeric characters other than the underscore (‘_’) in the module name.
2. General Instructions
These general instructions will be the same for each Python lab/MP. You will turn in a source file with your
functions in it. For this assignment, while you should use test cases, prior to turn in, you will comment out
each test case. Recall, in Python, comments are any line that starts with a ‘#’. For example, consider the
following code:
def func(a):
return a
print(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 of
the 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 2019
Page 2 of 3
So, before you turn in your code, comment out all your test cases, but NOT your functions. If you comment
out functions, you will not get credit for those functions (because as far as the interpreter is concerned, they
don’t exist). The grading script will remove any print and input statements not commented out and this may
break your code and result in a 0.
Testing: Remember when testing your function, don’t just test using the single example test case provided
to you. Try to think of possible cases that will cause your function to break! For example, if the function is
supposed to take a single string as input, test it with a string containing spaces, punctuation, etc. If the
CS 105作业代做、代写Python实验作业、Python程序语言作业调试、代做IDLE editor作业

function calculates an equation, pass in zero or negative numbers, or big numbers. If your function contains
loops or conditionals, test all edge cases of the conditionals and loops. The grading script will use between
five and ten test cases. You will not be given the test cases we choose prior to grading. It is part of your
assignment to come up with comprehensive testing. For the first few assignments, this will not be difficult.
3. Function One: countDown
Specification
The 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 get
NO credit if you use any loops (for, while, etc).
4. Function Two: myLSearch
Specification:
Assume you are given a sorted list of integers to search. Your job is to write a search algorithm to find the
index of a particular number.
CS 105 – Intro to Computing Non-Tech Spring 2019
Page 3 of 3
The 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 the
input 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: myRSearch
Specification:
Assume you are given a sorted list of integers to search. Your job is to write a search algorithm to find the
index 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 the
input 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.

因为专业,所以值得信赖。如有需要,请加QQ:99515681 或邮箱:[email protected]

微信:codinghelp

原文地址:https://www.cnblogs.com/comtopython/p/10821275.html

时间: 2024-11-09 05:46:45

CS 105 – Intro to Computing Non-Tech Spring 2019的相关文章

Spring 2019 HW1 MAT 331

Spring 2019 HW1 MAT 331Homework 1: MAT 331Due: 11:59pm, Feb 5, 2019Collaboration policy: You are welcome to work with others on this homework assignment. Butthe code and explanations you turn in should actually be written by you. In particular, you s

STAT 440 - Spring 2019 - Midterm Project

STAT 440 - Spring 2019 - Midterm ProjectRecall that you may use your notes, books, or even the internet to help answer these questions, but all of thework should be your own and you should not ask anyone for help or about any details related to the c

CS560/460 Spring 2019

CS560/460 Spring 2019Programming Assignment 1(Due February 12, 2019 by 11:59pm) 1.Geometric Primitives Drawing Description: The line drawing function is the basic function provided by many graphics tools, such as the MS Word, power point, etc. A numb

CS530, Spring 2019, Program Assignment

CS530, Spring 2019, Program Assignment #226 Feb 2019You and your team shall develop, test, and deliver a disassembler program for theXE variant of the SIC/XE family of machines.XE DISASSEMBLER REQUIREMENTS:The XE disassembler program shall open an XE

Math 353/DSC 301, Spring 2019, Final Exam

Math 353/DSC 301, Spring 2019, Final ExamPlease remember to write down your name and student ID. This is the take-home portion whichhas four problems. Only independently-finished and fully-justified answer will receive full credit.1. [11 = 3 + 2 + 4

The second curriculum design experiment report in spring 2019

2019年第二次课程设计实验报告 一.实验项目名称 贪吃蛇 二.实验项目功能描述 1.小蛇的移动 玩家可以通过 W A S D控制小蛇的上左下右移动,通过函数改变小蛇部位的位置 2.判断游戏失败 当小蛇与边框或自生发生碰撞时,游戏就算失败 四.实现界面展示 五.代码托管链接 https://gitee.com/The-king-of-the-apocalypse/two_storehouse 六.实验总结 问题:对于像这种分区式的,工作明确的函数问题,如何保证他们的相互协调发展 解决办法:暂时无

斯坦福CS课程列表

http://exploredegrees.stanford.edu/coursedescriptions/cs/ CS 101. Introduction to Computing Principles. 3-5 Units. Introduces the essential ideas of computing: data representation, algorithms, programming "code", computer hardware, networking, s

spring(6) 渲染web视图

[0]README 1)本文部分文字描述转自:"Spring In Action(中/英文版)",旨在review  "spring(6) 渲染web视图" 的相关知识: [1] 理解视图解析 [1.1]视图解析的基础知识以及spring 提供的其他视图解析器 1)spring mvc 定义了一个名为 ViewResolver的接口,如下 public interface ViewResolver { View resolveViewName(String view

Spring+SpringMVC+SpringDataJpa整合

一.思路: (一) Dao层与Service层: applicationContext.xml. a) 数据库连接池 b) 整合jpa c) 配置@service文件扫描器. d) 配置事务管理管理器,开启事务注解 e) 配置jpa扫描器 (二)Controller层: Springmvc.xml1.包扫描器,扫描@Controller注解的类.2.配置注解驱动.3.视图解析器. (三)web.xml 1. 配置spring容量监听器2. 配置前端控制器 二.构建项目 (一)构建maven项目,