CornellNotes Week 5 On Python
CornellNotes Week 5 On Python
Instructions: You must read the material and create an outline of the topics in your OWN words. Do not copy
the text from the tutorials into your notes. Make sure your outline contains notes for each subsection of the
reading assignment. Thoroughly cover each topic to show you have a firm understanding of the programming
concept or construct.
Ques NOTES:
Functions Decomposition
Decomposition in programming means breaking complex problems into smaller
parts called functions in Python. These functions solve common tasks or perform
specific operations, making them reusable across various programs and speeding
up development. Named functions with clear inputs and outputs allow users to use
them without needing to understand their inner workings, a concept known as
abstraction. Functions benefit programming by splitting large tasks, providing
reusable solutions, simplifying code creation and maintenance, and enabling the
assembly of complex systems by connecting functions based on their inputs and
outputs.
Functions
Functions in Python fall into two categories: Built-in and user-defined. Regardless
of their type, functions are always denoted by parentheses following their names,
which may or may not contain values. Learning about built-in functions involves
consulting categorized references to comprehend their purpose, required
information for execution, and the output they yield. This aligns with the concept of
abstraction—understanding functionality without delving into specifics.
Both user-defined and built-in functions follow a similar structure, as illustrated
below:
Week: ___Week 5___________ Name: _Theophilus Amaye__
Assignment: 5.2 Required Readings: Functions Class: _CS105-Section-03P
Page 2 of 5 Date: __Due 3-12-2023 __
Ques NOTES:
Using
(Calling) Positional Arguments
Functions
Week: ___Week 5___________ Name: _Theophilus Amaye__
Assignment: 5.2 Required Readings: Functions Class: _CS105-Section-03P
Page 3 of 5 Date: __Due 3-12-2023 __
Ques NOTES:
The program serves to calculate gross and net pay based on user-provided wage
and hours worked. It leverages three distinct functions: calcPay(), withholding(),
and main(), each contributing to the overall computation and presentation of
results.
calcPay(wage, hours):
Calculates the gross pay using the received wage and hours worked.
withholding(gross, percentage):
Computes the tax withholding based on the gross pay and a specified
percentage.
main():
Serves as the central function orchestrating the program's flow.
Prompts the user for wage and hours worked.
Calls calcPay() to compute gross pay and withholding() to determine taxes.
The order of arguments passed to a function determines their assignment to
the function's parameters.
In calcPay(wage, hours), the parameters wage and hours receive the
Week: ___Week 5___________ Name: _Theophilus Amaye__
Assignment: 5.2 Required Readings: Functions Class: _CS105-Section-03P
Page 4 of 5 Date: __Due 3-12-2023 __
Ques NOTES:
arguments user_wage and user_time respectively, despite having different
names.
What Does
Decomposition
Mean in
Computational
Thinking?
Week: ___Week 5___________ Name: _Theophilus Amaye__
Assignment: 5.2 Required Readings: Functions Class: _CS105-Section-03P
Page 5 of 5 Date: __Due 3-12-2023 __
Ques NOTES: