Ebook Introduction to programming concepts with case studies in python: Part 2

Part 2 book “Introduction to programming concepts with case studies in python” has contents: Managing the size of a problem, a measure for “solution hardness” - Complexity, organizing data, objects - Reunion of data and action. | Chapter 4 Managing the Size of a Problem As explained in Chap. 3, programming is all about world problems. Sometimes, a programmer needs to deal with program demands for • converting Celsius degree to Fahrenheit degree for the expected temperature in Paris tomorrow, • solving a quadratic equation for an unknown x, • calculating the edge lengths of a rectangle given the coordinates of the lower-left and upper-right corners. These tasks are ‘tiny’ in the sense that the required programming is merely about calculation of a few expressions. However, there are times when the demand is somehow different. For example, consider the case that the degree conversion is about all the cities in the world for each month of the year for the past 20 years. This now is a different case which requires a large amount of computation to be undertaken. In contrast to ‘tiny’, we call such problems ‘bulky’; these are problems where you can talk about the ‘size’ of the problem. Keeping the nature the same but changing the size, the problem varies from ‘tiny’ to ‘bulky’. We tackle such problems with two techniques: ‘recursion’, the most powerful weapon of the functional programming paradigm and the ‘iteration’ construct of the imperative paradigm. Interestingly, recursion is elegant, easier to understand but more difficult to build up. On the other hand, iteration is quick and dirty, easier to construct but more difficult to understand within an already written code. After having introduced both techniques, we will discuss and compare both techniques. An Action Wizard: Recursion The recursive-oriented approach is somewhat awkward for human understanding since we usually do not handle daily problems in a recursive manner. For example, it is quite hard to find a person who would define a postman’s work as a job carried out on a bag of letters, as follows: G. Üçoluk, S. Kalkan, Introduction to Programming Concepts with Case Studies in Python, DOI , © .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã 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.