tailieunhanh - Ebook The practice of computing using python (2nd edition): Part 2

(BQ) Part 2 book "The practice of computing using python" has contents: Functions—QuickStart, lists and tuples, more on functions, dictionaries and sets, more program development, introduction to classes, more on classes, program development with classes, files and exceptions II,. and other contents. | P A R T • 3 Functions and Data Structures Chapter 6 Functions—QuickStart Chapter 7 Lists and Tuples Chapter 8 More on Functions Chapter 9 Dictionaries and Sets Chapter 10 More Program Development This page intentionally left blank • C H A P T E R 6 Functions---QuickStart Function, the exercise, or executing of some office or charge. T. Blount, Glossographia, 1656, earliest definition of function in the Oxford English Dictionary YOU HAVE SEEN MANY EXAMPLES OF USING PYTHON BUILT-IN FUNCTIONS AND methods. In Section , we took at look at how functions work and how we could use them to manipulate string objects. In this chapter, you’ll learn how to create your own functions. The concept of a function should be familiar from its use in mathematics. Functions in programming languages share many of the characteristics of mathematical functions but add some unique features as well that make them more useful for programming. One of the main advantages for using functions is that they support divide-and-conquer problem solving. Remember divide-and-conquer from Section This technique encourages you to break a problem down into simpler subproblems, solve those subproblems, and then assemble the smaller solutions into the overall solutions. Functions are a way to directly encode the “smaller subproblem” solution. You’ll see more about this as we work through this chapter. W H A T I S A F U N C T I O N ? In mathematics, a function defines the relationship between values. Consider the function √ f (x ) ⇒ x . If you provide a particular value of x , ., x = 4, the function will perform a calculation (here the square root operation) and return the associated value, ., 2. Mathematicians term the variable x the argument to the function and say that the function returns the value 2. It is possible for a function to have multiple arguments—for example, a function that calculates multiplication requires two arguments: f (x , y ) ⇒ x ∗ y . However, a .

crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.