About this ebook
The presentation of the material is the same in each language, and much of the text is identical. Code samples are specific to the selected language, and some unique language features are unavoidably included, but the presentation is largely language-independent.
A unique feature of the book is that it explains how to acquire, install, and use freely available software to edit, compile, and run console programs on just about any system, including Windows and Mac. Its examples use command line compiling, so that the presentation remains focused on programming concepts and avoids becoming a training tool for a specific IDE.
The three-part organization of material starts with the basics of sequential processing, then adds branching and looping logic and subprograms, and ends with arrays and objects. It turns a beginner with no programming experience into a programmer, prepared to continue their training in Python or just about any other specific programming language.
Robert Burns
Robert Burns, now retired, spent 40 years teaching and researching in universities around the world. From training students to be geography teachers in University Departments of Education, and ‘A’ level examiner in physical geography, he later used his deep interest in the psychological aspects of student learning and motivation to study and qualify as a psychologist. In retirement, the climate ‘wars’ redirected his interest back to Earth sciences. Burns is an experienced author with over 20 texts published by major publishing houses including Longmans, Sage, Allen and Unwin, Kluwer, and Addison-Wesley.
Read more from Robert Burns
The Christmas Library: 250+ Essential Christmas Novels, Poems, Carols, Short Stories...by 100+ Authors Rating: 5 out of 5 stars5/5Programming Concepts in C++ Rating: 0 out of 5 stars0 ratings50 Classic Love Poems You Have To Read (Golden Deer Classics) Rating: 5 out of 5 stars5/5Poems and Songs of Robert Burns Rating: 0 out of 5 stars0 ratingsThe Merry Muses of Caledonia Rating: 0 out of 5 stars0 ratingsThe Greatest Christmas Stories: 120+ Authors, 250+ Magical Christmas Stories Rating: 0 out of 5 stars0 ratingsProgramming Concepts in Java Rating: 0 out of 5 stars0 ratingsSelected Poetry Rating: 0 out of 5 stars0 ratingsThe Essential Robert Burns: 500+ Poems and Songs by the National Poet of Scotland Rating: 0 out of 5 stars0 ratingsPoems and Songs of Robert Burns Rating: 0 out of 5 stars0 ratingsThe Complete Works of Robert Burns: Containing His Poems, Songs, and Correspondence Rating: 0 out of 5 stars0 ratingsHo! Ho! Ho! Santa Claus' Reading List: 250+ Vintage Christmas Stories, Carols, Novellas, Poems by 120+ Authors Rating: 0 out of 5 stars0 ratingsRealms Beyond - Crafting Fantasy Worlds Rating: 0 out of 5 stars0 ratingsLuath Kilmarnock Edition: Poems, Chiefly in the Scottish Dialect: 250th Anniversary Edition Rating: 0 out of 5 stars0 ratingsPoems and Songs of Robert Burns Rating: 0 out of 5 stars0 ratingsEvergreen Christmas Readings Rating: 4 out of 5 stars4/5
Related to Programming Concepts in Python
Related ebooks
Python Handbook For Beginners. A Hands-On Crash Course For Kids, Newbies and Everybody Else Rating: 0 out of 5 stars0 ratingsPython Made Simple: Learn Python programming in easy steps with examples Rating: 5 out of 5 stars5/5Python: Beginner's Guide to Programming Code with Python: Python Computer Programming, #1 Rating: 0 out of 5 stars0 ratingsPython for Beginners: A Crash Course to Learn Python Programming in 1 Week Rating: 0 out of 5 stars0 ratingsBasics of Python Programming: Embrace the Future of Python Rating: 0 out of 5 stars0 ratingsEssential Python 3 Rating: 0 out of 5 stars0 ratingsConceptual Programming: Conceptual Programming: Learn Programming the old way! Rating: 0 out of 5 stars0 ratingsPython In - Depth: Use Python Programming Features, Techniques, and Modules to Solve Everyday Problems Rating: 0 out of 5 stars0 ratingsPython from the Very Beginning Rating: 0 out of 5 stars0 ratingsPython Programming for Beginners Rating: 3 out of 5 stars3/5Learn Python Programming the Easy and Fun Way Rating: 1 out of 5 stars1/5Python Rating: 0 out of 5 stars0 ratingsBasics of Python Programming: Learn Python in 30 days (Beginners approach) - 2nd Edition Rating: 0 out of 5 stars0 ratingsPython for Developers: Learn to Develop Efficient Programs using Python Rating: 0 out of 5 stars0 ratingsPython: Best Practices to Programming Code with Python Rating: 0 out of 5 stars0 ratingsPython Programming Rating: 0 out of 5 stars0 ratingsPython: Beginner's Guide to Programming Code with Python Rating: 0 out of 5 stars0 ratingsProblem Solving in C and Python: Programming Exercises and Solutions, Part 1 Rating: 5 out of 5 stars5/5Python Mastery: From Absolute Beginner to Pro Rating: 0 out of 5 stars0 ratingsAbsolute Beginner's Python Programming: The Illustrated Guide to Learning Computer Programming Rating: 1 out of 5 stars1/5Python Programming for Kids: Fun and Easy Guide to Building Your First Programs Rating: 0 out of 5 stars0 ratingsPython: Best Practices to Programming Code with Python: Python Computer Programming, #2 Rating: 0 out of 5 stars0 ratingsPython Programming: Your Beginner Guide To Learn Python in 7 Days Rating: 4 out of 5 stars4/5
Computers For You
Algorithms to Live By: The Computer Science of Human Decisions Rating: 4 out of 5 stars4/5Mastering ChatGPT: 21 Prompts Templates for Effortless Writing Rating: 4 out of 5 stars4/5Get Into UX: A foolproof guide to getting your first user experience job Rating: 4 out of 5 stars4/5Storytelling with Data: Let's Practice! Rating: 4 out of 5 stars4/5UX/UI Design Playbook Rating: 4 out of 5 stars4/5Everybody Lies: Big Data, New Data, and What the Internet Can Tell Us About Who We Really Are Rating: 4 out of 5 stars4/5Creating Online Courses with ChatGPT | A Step-by-Step Guide with Prompt Templates Rating: 4 out of 5 stars4/5Explain the Cloud Like I’m 10 Rating: 5 out of 5 stars5/5Simply Linux: Basics Rating: 5 out of 5 stars5/5Everyday UX: 10 Successful UX Designers Share Their Tales, Tools, and Tips for Success Rating: 4 out of 5 stars4/5Hands-On Motion Graphics with Adobe After Effects CC: Develop your skills as a visual effects and motion graphics artist Rating: 0 out of 5 stars0 ratingsBlender 3D Basics Beginner's Guide Second Edition Rating: 5 out of 5 stars5/5Fundamentals of Programming: Using Python Rating: 5 out of 5 stars5/53D Animation Essentials Rating: 3 out of 5 stars3/52022 Adobe® Premiere Pro Guide For Filmmakers and YouTubers Rating: 5 out of 5 stars5/5C# 10.0 All-in-One For Dummies Rating: 0 out of 5 stars0 ratingsData Analytics for Beginners: Introduction to Data Analytics Rating: 4 out of 5 stars4/5Data Science For Dummies Rating: 4 out of 5 stars4/5Cloud Computing For Dummies Rating: 5 out of 5 stars5/5Introduction to Computer Fundamentals Rating: 4 out of 5 stars4/5Elon Musk Rating: 4 out of 5 stars4/5100 More Things Every Designer Needs To Know About People Rating: 4 out of 5 stars4/5The Innovators: How a Group of Hackers, Geniuses, and Geeks Created the Digital Revolution Rating: 4 out of 5 stars4/5
Reviews for Programming Concepts in Python
0 ratings0 reviews
Book preview
Programming Concepts in Python - Robert Burns
PART 1: The Basics
Chapter 1. Programming Concepts
Programmers give instructions to computers in the form of computer programs
. Internet Explorer, Firefox, Word, Angry Birds, TurboTax, AutoCAD, etc., are all computer programs. They were developed by programmers and are used by other people to convert their typed, touched, spoken, clicked, and pasted input into some useful or entertaining form of output. The activity whereby programmers actually create computer programs is called programming
.
Programming involves three main steps: (1) understanding the problem to be solved, (2) writing computer code
in a human-friendly computer language, and (3) translating the code into computer-readable form (like the 0’s and 1’s you see in science fiction movies). The first step is where human intelligence comes in – you certainly must understand something before you can explain it to someone else, like a computer. The second step involves using another computer program known as an editor
to write in a computer language, like Basic, C, C++, C#, Java, PHP, Python, etc. The last step involves using another computer program (called an interpreter
or compiler
) to translate code into something a computer can understand. In this book you will learn these three steps.
1.1 The First Step, Understanding
Alas, this is the part that new programming students tend to minimize and overlook. As a result, they end up being able to create very simple programs after a couple of months of study, but are unable to progress beyond that skill level. This happens because the first examples of programming and the first assignments are usually very easy problems (like add two and two
), and to spend any time thinking how to solve such problems seems ludicrous. It’s just easier to learn the mechanics of code editing and compiling without having to also devise solutions to complicated problems. So we tend to skip directly to the second step, code editing.
This works for a while, but eventually the problems get a bit harder (like count the number of test scores that are above the average
). That’s when we get stuck, because we never developed the habit of thinking, understanding, and planning before coding begins.
So here’s a compromise: we will not focus on understanding at first, so as not to dismiss the concept due to its apparent irrelevance. But later on in this book, when the solutions to problems are no longer obvious, the discipline of understanding and planning will be reintroduced in the form of algorithms
.
1.2 Editors
An editor
is a program used by programmers to write computer code. Code is a set of instructions that tells the computer how to collect input, process it, and express the results as output. These instructions are not exactly written in English, although they do resemble instruction sets that you may have seen in cooking (also known as recipes
) or after you buy something that has some assembly required
.
Code is written in a computer language
. Computer languages are simplified and strict versions of English. They are simplified in the sense that they include a very small subset of words from the English language, such as if
, while
, for
, break
, continue
, and only a hundred or so others. Computer languages are also strict in the sense that you have to say things and punctuate things just right, or the computer will not understand you. You even have to spell precisely, and use uppercase where you are supposed to, and use lowercase where you are supposed to, or the computer will not know what you are talking about! It takes intelligence to understand nuances of language, like accents, mispronunciations, incorrect choice of words, and misspellings – and remember that it’s the humans who have the intelligence here, and not the computers.
There are three categories of editors that are typically used for programming, as explained below: general-purpose text editors, code editors, and IDE editors.
1.2.1 Text Editors
Using the vocabulary and grammar of a computer language, programmers type instructions in an editor. Any text editor will do, including Windows Notepad, UNIX or Linux vi, and Apple MacOSx TextEdit. These are general-purpose text editors, not specifically designed for use in coding, but they work fine.
Word, Pages, and other editors capable of rich text formatting
are not very suitable for coding. They are page-oriented, and they embed formatting information into the files they produce. While it is possible to configure such editors for text editing, it is better to avoid them.
1.2.2 Code Editors
Code editors are special-purpose text editors created specifically for code editing. Code editors may include such useful features as code templates, line numbers, and syntax highlighting. Many code editors are available on the Internet for free download and installation, or for a reasonable price. Popular ones include Notepad++, Bluefish, TextWrangler, Emacs, Crimson, jEdit, JNotePad, to name a few.
1.2.3 IDEs
Finally there are the editors that are bundled with high-powered, interactive development environments, or IDEs
for short. Python programmers often use products like NetBeans, Aptana Studio, PyCharm, and websites like repl.it. IDEs have some very useful features to help programmers, such as visual drag-and-drop development interfaces, and one-button run.
IDEs are the most complicated of the editor choices, and beginners really should avoid them. It’s possible for an introductory computer course using an IDE to be too much about the tool at the expense of the subject: programming concepts. So while any editor choice is acceptable for use as you follow this book, the examples shown here use the Windows PC NotePad text editor and Apple Mac TextEdit.
1.3 Interpreters And Compilers
An interpreter
is used by programmers to convert human-programmer-readable code into computer programs. They are sometimes also referred to as compilers
.
Python differs from the C++ and Java languages in that program execution is just a one-step. C++ and Java involve two steps – one to create a new version of the programmer’s code and save it in a new file, and another step to execute that version of the program. Python does it all without an intermediate file.
In the C++/Java two-step process, any programming mistakes are caught in the first step, so by the time the second step gets done, those errors are worked out. In Python’s one step, programming errors don’t make themselves known until program execution reaches them.
1.4 Elements Of Computer Languages
Before you can type anything useful into an editor and save it to a file to be run later, you need to know some basics about computer languages. There are programming concepts that are common to all computer languages, and it would be nice to write an introductory book like this at the conceptual level instead of focusing on a specific language. But it is impractical to do so. We cannot get very far without typing some code, and that means choosing a language in which to work. Python is the language used in this book.
1.4.1 Statements And Expressions
A good way to explain the basic elements of computer languages is to compare them to the written English language. Text written in the English language consists of sentences; computer code consists of statements. While English sentences contain of phrases, computer statements contain of