Programming with Structured Flowcharts and Essential Python
()
About this ebook
Related to Programming with Structured Flowcharts and Essential Python
Related ebooks
Confident Programmer Problem Solver: Six Steps Programming Students Can Take to Solve Coding Problems Rating: 0 out of 5 stars0 ratingsIELTS Writing Task 1: Interactive Model Answers & Practice Tests Rating: 5 out of 5 stars5/5Beginning Software Engineering Rating: 4 out of 5 stars4/5Practical Design of Experiments: DoE Made Easy Rating: 4 out of 5 stars4/5DevOps For Beginners: DevOps Software Development Method Guide For Software Developers and IT Professionals Rating: 0 out of 5 stars0 ratingsSolidWorks Flow Simulation 2018 Black Book Rating: 3 out of 5 stars3/5SolidWorks Flow Simulation 2021 Black Book Rating: 0 out of 5 stars0 ratingsJump Start Git Rating: 0 out of 5 stars0 ratingsSolidWorks Flow Simulation 2020 Black Book Rating: 5 out of 5 stars5/5Improving the Quality of ABAP Code: Striving for Perfection Rating: 0 out of 5 stars0 ratingsEffective Experimentation: For Scientists and Technologists Rating: 2 out of 5 stars2/5IELTS Writing Task 1 Interactive Model Answers, Practice Tests, Vocabulary & Test Tips Rating: 4 out of 5 stars4/5Analysis and Design of Algorithms: A Beginner’s Hope Rating: 0 out of 5 stars0 ratingsGoogle BigQuery Analytics Rating: 3 out of 5 stars3/5Learn Docker - .NET Core, Java, Node.JS, PHP or Python: Learn Collection Rating: 5 out of 5 stars5/5How to Upgrade Captiva InputAccel Rating: 0 out of 5 stars0 ratingsISTQB Certified Tester Foundation Level Practice Exam Questions Rating: 5 out of 5 stars5/5Anyone Can Create an App: Beginning iPhone and iPad programming Rating: 0 out of 5 stars0 ratingsLearn AI-assisted Python Programming: With GitHub Copilot and ChatGPT Rating: 0 out of 5 stars0 ratingsLearn Kubernetes - Container orchestration using Docker: Learn Collection Rating: 4 out of 5 stars4/5Test Driven: Practical TDD and Acceptance TDD for Java Developers Rating: 0 out of 5 stars0 ratingsTOGAF® 9.2 Level 2 Scenario Strategies Wonder Guide Volume 1 – 2023 Enhanced Edition: TOGAF® 9.2 Wonder Guide Series, #4 Rating: 0 out of 5 stars0 ratingsExcel VBA 24-Hour Trainer Rating: 3 out of 5 stars3/5BluePrint for Software Engineering Rating: 0 out of 5 stars0 ratingsLearn WPF MVVM - XAML, C# and the MVVM pattern Rating: 4 out of 5 stars4/5Visual Studio Code: End-to-End Editing and Debugging Tools for Web Developers Rating: 0 out of 5 stars0 ratingsJava with TDD from the Beginning Rating: 0 out of 5 stars0 ratings
Programming For You
Python Programming : How to Code Python Fast In Just 24 Hours With 7 Simple Steps Rating: 4 out of 5 stars4/5SQL QuickStart Guide: The Simplified Beginner's Guide to Managing, Analyzing, and Manipulating Data With SQL Rating: 4 out of 5 stars4/5HTML & CSS: Learn the Fundaments in 7 Days Rating: 4 out of 5 stars4/5Coding All-in-One For Dummies Rating: 4 out of 5 stars4/5Learn to Code. Get a Job. The Ultimate Guide to Learning and Getting Hired as a Developer. Rating: 5 out of 5 stars5/5Hacking: Ultimate Beginner's Guide for Computer Hacking in 2018 and Beyond: Hacking in 2018, #1 Rating: 4 out of 5 stars4/5PYTHON: Practical Python Programming For Beginners & Experts With Hands-on Project Rating: 5 out of 5 stars5/5Grokking Algorithms: An illustrated guide for programmers and other curious people Rating: 4 out of 5 stars4/5SQL All-in-One For Dummies Rating: 3 out of 5 stars3/5Java for Beginners: A Crash Course to Learn Java Programming in 1 Week Rating: 5 out of 5 stars5/5Learn PowerShell in a Month of Lunches, Fourth Edition: Covers Windows, Linux, and macOS Rating: 0 out of 5 stars0 ratingsPython Projects for Beginners: A Ten-Week Bootcamp Approach to Python Programming Rating: 0 out of 5 stars0 ratingsThe Unofficial Guide to Open Broadcaster Software: OBS: The World's Most Popular Free Live-Streaming Application Rating: 0 out of 5 stars0 ratingsPokemon Go: Guide + 20 Tips and Tricks You Must Read Hints, Tricks, Tips, Secrets, Android, iOS Rating: 5 out of 5 stars5/5Teach Yourself C++ Rating: 4 out of 5 stars4/5SQL: For Beginners: Your Guide To Easily Learn SQL Programming in 7 Days Rating: 5 out of 5 stars5/5The Little SAS Book: A Primer, Sixth Edition Rating: 5 out of 5 stars5/5Python: For Beginners A Crash Course Guide To Learn Python in 1 Week Rating: 4 out of 5 stars4/5Excel : The Ultimate Comprehensive Step-By-Step Guide to the Basics of Excel Programming: 1 Rating: 5 out of 5 stars5/5101 Amazing Nintendo NES Facts: Includes facts about the Famicom Rating: 4 out of 5 stars4/5
Reviews for Programming with Structured Flowcharts and Essential Python
0 ratings0 reviews
Book preview
Programming with Structured Flowcharts and Essential Python - Achla Agarwal
Programming with Structured Flowcharts
and
Essential Python
Krishna Kumar Agarwal
Achla Agarwal
© 2022
Preface
Although structured flowcharts have been in use for less than a decade, they have found wide acceptance as an aid to developing software. They may be used for writing new algorithms in a step-wise manner or they may be used for documenting existing programs. The major advantage of structured flowcharts is that they make the control section of a program easier to understand. This is especially true when the person revising the program is different from the one who wrote it—a very common practice. Since it is difficult to make a structured flowchart larger than a page, it automatically encourages modularization of a large program.
Opponents of flowcharts say that they are worthless either for documentation or as an aid to algorithm development. Clearly, this is a matter of opinion. Familiarity with these flowcharts could make the above-mentioned tasks easier. If it does not, one could just as easily discard structured flowcharting, providing it does not make someone else’s task any harder. Selfish programming is certainly not good practice.
This book has been written to emphasize the point that algorithm development is the most difficult part of writing a program. Programming itself must be done only when the algorithm has been completed and checked out carefully tracing the flowchart.
Anyone with only a basic knowledge of mathematics should be able to follow the material of this book; however, like mathematics, programming can only be learned with a lot of practice and patience. Hence, the reader is encouraged to try out as many problems as possible, selecting any suitable programming language for each problem.
Even though we have deemphasized the importance of programming languages for learning how to program, every algorithm must be programmed in a language to check its correctness. Python has been included in an attempt to convince the reader that algorithm development must be given much more thought than the almost routine task of converting a flowchart to a program.
Sincere thanks are due to our friend Jay Jain for debugging
this book and to our parents for encouraging its development. Many students contributed by telling us what they disliked about many intermediate versions of this book. The editors at Petrocelli Books, Inc. have been very helpful in making improvements. Thanks are also due to McGraw-Hill for granting us permission to copy parts of the first edition, Programming with Structured Flowcharts, first published in 1984.
krishna_agarwal@hotmail.com Krishna Kumar Agarwal
achla1@hotmail.com Achla Agarwal
Table of Contents
Chapter one
An Introduction to Solving Problems
Some Common Problems and Procedures
Standard Flowcharts
Structured Flowcharts
Exercises
Chapter two
Basic Concepts in Problem Solving
The Ability to Compare Data Items
The Ability to Perform Simple Logical Operations
The Ability to Store Information
The Ability to Input and Output Data
The Ability to Repeat a Set of Operations
Chapter three
Simple Problems and Their Flowcharts
Iteration-Free Problems
Problem 3.1:
Problem 3.2:
Problem 3.3:
Exercises
Problems Requiring Simple Iteration
Problem 3.5:
Problem 3.6:
Problem 3.7:
Problems Conducive to Nested
Iteration
Problem 3.8:
Problem 3.9:
Problem 3.10:
Exercises
Chapter four
Subscripted Variables
The Python Program for Figure 4.1
Reversing the Input Sequence
Problem 4.1:
Bubble Sorting
Problem 4.2:
Fibonacci Series
Problem 4.3:
Sequential Search
Problem 4.4:
Binary Search
Problem 4.5:
Merge Sorting
Problem 4.6:
Students’ Grades
Problem 4.7:
Matrix Addition
Problem 4.8:
Matrix Multiplication
Problem 4.9:
Exercises
Chapter five
Subroutines and Functions
Greatest Common Divisor
Problem 5.1:
Minimum Value Computation
Problem 5.2:
Perfect Square Computation
Problem 5.3:
Matrix transposition
Problem 5.4:
Connectivity of a Graph
Problem 5.5:
Exercises
Chapter six
Recursive Subprograms
Factorial Computation
Problem 6.1:
Greatest Common Divisor
Problem 6.2:
Fibonacci Series
Problem 6.3:
Recursion with Two Functions
Problem 6.4:
Hamiltonian Path Search
Problem 6.5:
Exercises
APPENDIX I
APPENDIX II
Index
Chapter one
An Introduction to Solving Problems
Some Common Problems and Procedures
In daily life we follow so many procedures that they get built into our subconscious and we fail to recognize them as instructions meant for solving problems. Most of these procedures have been taught to us at school and at home. Some have been learned by trial-and-error or by experience. Rather than addressing procedures in the abstract, let us consider a few problems and some common ways of solving them.
Example 1.1:
Problem
: Putting on a pair of shoes and socks
Procedure
: (a) Select a pair of matching socks.
(b) Put the left
sock on the left foot, and the other sock on the right foot.
(c) Select a pair of matching shoes of the correct size.
The shoes must also match the color of the socks.
(d) Put the left
shoe on the left foot, and the other shoe on the right foot.
(e) If the shoes have laces, tie them properly.
This procedure is so simple that discussing it further seems absurd. However, simple thought it may be, it reveals a very important characteristic of procedures, namely, the importance of doing things in their proper sequence.
Some results of not following the procedure are:
Some of these might be your objective, for example if you are auditioning for a circus. In that case you would be following another procedure anyway.
Example 1.2:
Problem
: Making lentil soup.
Procedure
: (a) Add 1 liter of water and 1 cup of lentils in a large pot.
(b) Boil for 10 minutes.
(c) Add 1 chopped carrot and 1 chopped onion.
(d) As long as not cooked. repeat steps (d1) and (d2):
(d1) Keep boiling. Stir.
(d2) Add more water if soup thickens too much.
(e) Add 1 teaspoon (4 c.c.) of salt.
(f) Add other spices.
(g) Cook 2 more minutes and keep stirring.
Once again we note the importance of doing things in the correct sequence. Obviously, exchanging steps (c) and (g) will produce soups containing raw carrots and onion.
Step (d) illustrates the concept of indefinite iteration,
that is, steps (d1) and (d2) must be repeated as long as the soup is not cooked. Step (d) may be replaced by the following sequence (d’) if it is known that sub-steps (d1) and d2) have to be repeated for only 20 minutes.
(d’) Repeat for 20 minutes:
(d1) Keep boiling. Stir.
(d2) Add more water if soup thickens too