Introduction
Welcome to unit 4!
Unit 4 offers thorough coverage of the concept of function, a segment of code that executes a particular set of instructions
.
You will learn how the function is “called” or executed from within other programs and how data can be passed to the function as a series of arguments during the course of the function’s execution. Additionally, you’ll learn how functions can return a limited amount of data by returning a value—a return value—to the calling program.
The reading for Unit 4 covers techniques for using functions with return values to deal with complexity. You’ll discover how Boolean functions, when used in conditional statements, can be used to encapsulate complex tests. Additionally, you will become familiar with Composition, the technique where a function builds up a complex return value by calling simpler functions. You’ll also see how the concept of composition can be used with recursion to carry out interesting calculations. The last section of Unit 4 explains how the Functions are especially useful for incremental development, a crucial approach to handling complexity.
Reference
“Boolean Operators Spock” by mwscheung is licensed under CC BY-NC 2.0. To view a copy of this license, visit
https://creativecommons.org/licenses/by-nc/2.0/?ref=openverse
.
Read
ing Assignment
Reading Assignments are designed to expand your knowledge of the topics introduced in the Overview and provide the knowledge you will need to successfully complete the assignments in this unit. As you read through the learning resource and watch the videos consider the following:
- What is the incremental development process?
- What is a leap of faith?
- How does Python implement the return of function values?
Read
Think Python: How to think like a computer scientist
Chapter 6 – Fruitful Functions
Watch: Python Beginner Tutorial 3 – Function Return Values and Debugging
References
Downey, A. (2015). Think Python: How to think like a computer scientist. Green Tea Press.
https://greenteapress.com/thinkpython2/thinkpython2.pdf
Discussion Assignment
Welcome to the Unit 4 Discussion Forum!
Section 6.9 Debugging of your textbook lists three possibilities to consider if a function is not working.
- Describe each possibility in your own words.
- Define “precondition” and “postcondition” as part of your description.
- Create your own example of each possibility in Python code. List the code for each example, along with sample output from trying to run it.
The code and its output must be explained technically whenever asked. The explanation can be provided before or after the code, or in the form of code comments within the code. For any descriptive type of question, Your answer must be at least 150 words.
End your discussion post with one question related to programming fundamentals learned in this unit from which your colleagues can formulate a response or generate further discussion. Remember to post your initial response as early as possible, preferably by Sunday evening, to allow time for you and your classmates to have a discussion.
Your instructor will grade this assignment using this rubric.Reference
Programming Assignment
Assignment Instructions:
This assignment will assess your skills and knowledge in developing a function through an incremental development process such that the debugging becomes fast. There are two parts of this assignment, and you must submit both parts.
Part 1
You work as a software developer in a company that creates custom software solutions for various clients. Your company has been approached by an educational client who wants to develop a function that calculates the length of the hypotenuse of a right triangle given the lengths of the other two legs as arguments. Your manager has instructed you to use incremental development to create the necessary function and document each stage of the development process. After completing the final stage of development, you have to test the function with different arguments and record the outputs in your Learning Journal.
Tasks
Include all of the following in your submission:
- An explanation of each stage of development, including code and any test input and output.
- The output of hypotenuse(3,4).
The output of two additional calls to hypotenuse with different arguments.
Part 2
You are a software developer who wants to establish yourself as a skilled and versatile programmer. To achieve this, you have decided to create a work portfolio that showcases your ability to develop custom software solutions. This portfolio will be your gateway to attract potential clients and establish yourself as a freelancer.
As part of your portfolio, you plan to create your own function that does some useful computation using an incremental development approach that will demonstrate your programming skills and problem-solving abilities. You will document each stage of the development process, including the code and any test input and output in your Programming Assignment.
Submission Instruction
- Submit your answer in one document. Clearly write part 1 and part 2 before your answer.
- An explanation of each stage of development, including code and any test input and output.
- The code and its output must be explained technically. The explanation can be provided before or after the code, or in the form of comments within the code. For code modification type of questions, always mention or clearly highlight the part, which is modified, along with the reason stated, as a code comment.
- The descriptive part of your response must be at least 200 words.
Include the following in your submission:
The output of three calls to your function with different arguments.
If you use an informational source, be sure to identify the source and share the link to the source you used.
Reference
Downey, A. (2015). Think Python: How to think like a computer scientist. Needham, Massachusetts: Green Tree Press.
https://greenteapress.com/thinkpython2/thinkpython…
This assignment will be assessed by your instructor using the rubric available on the assignment page located on the course homepage.
RUBRIC – CS 1101 – DISCUSSION FORUM UNIT 1 to UNIT 4
Level 4
Level 3
Level 2
Criteria
Posts well-developed
Code
&Explanation assignment that fully
addresses and develops all
of the code aspects of the task.
2
Posts well-developed
Post
assignment that fully
question
addresses and develops all
related to
aspects of the task.
programming
fundamental
1
Level 1
Posts well-developed
Posts adequate
Posts no assignment
assignment that
assignment with
addresses all aspects of superficial thought and
the task; lacks full
preparation; doesn’t
development of
address all aspects of
concepts.
the task.
1.6
1
0
Weight
3%
Posts well-developed
Posts adequate
Posts no assignment
assignment that
assignment with
addresses all aspects of superficial thought and
the task; lacks full
preparation; doesn’t
development of
address all aspects of
concepts.
the task.
0.8
0.5
0
1%
No connections are made
Connection Strong, direct connections are Some direct connections Minimal direct
made to readings and/or
are made to readings
connections are made to to readings or other
to course
other course materials
and/or other course
readings and/or other course materials
materials
(readings/resources/etc.) and materials
course materials
(readings/resources/etc.),
are clearly stated.
(readings/resources/etc.) (readings/resources/etc.) and/or if made, are not
and are clearly stated for Connections are largely clearly stated and are
the most part.
inferred and somewhat largely personal
unclear at times.
opinions.
1
0.8
0.5
1%
0
Peer
Feedback
Replies
Clarity and
Mechanics
Actively engaged in the
discussion forums with at
least three (3) postings of
other students
No replies to other
Actively engaged in
Actively engaged in
the discussion forums the discussion forums students
with at least two (2) with at least one (1)
postings of other
posting of other
students
students
3
2.4
1.5
Replies show insight, depth, &
understanding. They connect
with the original post and add
to that post by including
references to supporting
material (e.g., URLs, files).
Personal opinion is
appropriately expressed &
clearly related to the original
post.
Replies are rather simple
but show some insight,
depth, or connection to
the original post. Some
material may be
irrelevant, but personal
opinion is appropriately
expressed & posts as a
whole show
understanding.
Simple replies that lack No replies
insight, and depth, or are
superficial. Entries tend
to be short and
frequently irrelevant to
the original post. Does
not express opinion
clearly. Shows little
understanding.
2
1.6
1
Posting is polished and
generally free of errors in
mechanics, spelling, usage,
and sentence structure.
Posting is polished but
may contain minor
errors in mechanics,
spelling, usage, and
sentence structure.
1
0.8
Posting is adequate but Posting has numerous
may contain some
errors in mechanics,
errors in mechanics,
usage, spelling, and
spelling, usage, and
sentence structure.
sentence structure but Errors interfere with
errors do not interfere readability.
with understanding.
0.5
0
0
0
3%
2%
1%