Discover millions of ebooks, audiobooks, and so much more with a free trial

Only $11.99/month after trial. Cancel anytime.

Programming Concepts in Python
Programming Concepts in Python
Programming Concepts in Python
Ebook320 pages2 hours

Programming Concepts in Python

Rating: 0 out of 5 stars

()

Read preview

About this ebook

Programming Concepts in Python is one in a series of books that introduce the basic concepts of computer programming, using a selected programming language. Other books in the series use languages like C++ and Java, but all focus on concepts and not on any particular language.
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.
LanguageEnglish
PublisherXlibris US
Release dateJun 19, 2015
ISBN9781503575561
Programming Concepts in Python
Author

Robert Burns

Robert Burns has been involved in the areas of self improvement and assisting people in becoming who they were meant to be from birth. He knows that stories play a significant role in our life's choices and future accomplishments. This short story has a wealth of information concerning friendship so I hope you enjoy the book as much as I enjoyed writing it.

Read more from Robert Burns

Related to Programming Concepts in Python

Related ebooks

Computers For You

View More

Related articles

Reviews for Programming Concepts in Python

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    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

    Enjoying the preview?
    Page 1 of 1