Concept
|
Page(s)
|
Description
|
Alphanumeric
|
Data & Data Types
|
Alphanumeric characters include the alphabetic letters A thru Z, both upper case and lowercase, as well as the digits 0 thru 9. When a digit is within an alphanumeric value, it is not considered a number but rather a textual representation of the digit. Alphanumeric also includes other characters found in keyboards, such as @ $ # & * ( ) { } [ ] , = - _ . + ; ' /. Also, a blank space (created on the keybard by the spacebar) is considered alphanumeric.
|
Case-Sensitivity
|
Write Your First Program
|
Some programming languages are case-sensitive. This means that commands, variables, functions, methods, etc. used in your code must be either lower or upper case as outlined in the definition of that language. Python is a case-sensitive language. For example, in Python we use a function called print very often. Based on the specificiation for Python, that function name must be lower-case when you use it in your code. If you were to type it as PRINT and try to run your program, it would report an error.
|
Casting
|
User Input
|
In programming we often need to convert values of one data type into another data type, this process is called casting. There are two types of casting: implicit and explicit. Implicit casting is automatically handled by the Python interpreter when needed, for example, when dividing two integers and the resulting value is a floating point number. Explicit casting is when the programmer uses built-in functions to intentionally cast one data type to another.
|
Condition
|
Decisions: if Statements
|
Condition: A condition is a statement or process that returns a result of either True or False. That result is often then used to make decisions. For example, let's say we want to write a very simple guessing game where we prompt the user for a number between a low and high range and if they guess right we let them know they guessed right.
|
Data
|
Data & Data Types
|
Data are units of information. Often the words data and information are used interchangeably, but that is actually a mistake. The common academic definition of information is that which is conveyed or represented by a particular arrangement or sequence of symbols.
|
Escape Sequence
|
Data & Data Types
|
A combination (sequence) of alphanumeric characters that has a meaning and purpose within the programming language. These sequences of characters are interpreted by the interpreter and acted on based on their purpose.
|
Evaluation
|
Print Function
|
Evaluation: I have used the term evaluate a number of times so far, but what does that mean in the context of programming? Evaluation in programming means that we examine the result of something and, usually, take some action based on result of the evaluation. So, for example, if I write
x = 10
y = 2
z = x * y
How might I examine the value of z? I could print it, but what if I needed to know whether the value of z is above or below a certain value? I can evaluate that question as a decision (a.k.a. a conditional statement).
if z > 15:
# do something
With this if statement I am evaluating the value of z as a condition, in this example the condition of z > 15 will evaluate to True, so my # do something code will run.
|
Functions
|
Print Function
|
A function in programming is a self-contained block of code (sometimes called a module) that performs a specific task. Functions are very useful, particularly when the task they perform is needed frequently in a software system. Most programming languages, such as Python, have built-in functions available for programmers to use. Also, programmers can write their own functions to create customized reusable functionality for their programs.
|
Indentation
|
Decisions: if Statements
|
Indentation: In Python, indentation is significant for certain syntax structures. Notice in the general form above, that code_block is indented. This is a requirement in Python if statements. All code that is part of the code block must be indented, this is how the interpreter knows what code is included in the block of code to run when the if statement condition evaluates to True.
|
Iterable
|
for Loop
|
To iterate means to repeat one or more steps in a process, each repetition is a single iteration and the outcome of one iteration is then the starting point of the next iteration. The end of iteration is controlled by some condition. So, in Python, an iterable is anything we can use to iterate, that is repeat, an action on. For example, strings are iterables. We can repeatedly read one character of a string and print that single character, so each single-character read is an iteration and the condition that ends the iteration is when we run out of characters to read (end of the string).
|
Methods
|
Strings
|
Methods in programming are procedures associated with objects which provide functionality related to that object.
|
Objects
|
Print Function
|
In programming, an object is a very important concept but can be difficult to understand. At this early stage in this eBook, I will provide a simple (incomplete) definition to start with, and then we will build upon this definition as we progress through this eBook.
As an introductory definition, let's use the concept of a noun in human language. A noun is a person, place or thing. We often refer to things as objects. Further, we often describe objects by their attributes (color, shape, size, etc.) and by their behaviors, or actions (fly, roll, spin, etc.). For example, the word bicycle is a noun that represents a thing (an object) that we are familiar with. We could say "that bike is red (attribute) and it has two wheels that roll (behavior)."
In many programming languages, like Python, we have a similar conceptual approach and terminology. There are many things (objects) in Python, such as date objects, video, audio, data, people, bicycles, etc. You may be wondering how that's possible, a bicycle in Python? As we proceed, I'll point out objects that already exist in Python, their attributes and behaviors. Also, we'll learn to create our own objects as well. We will also see tools in Python, such as functions, that help us work with objects. The first of these functions that we'll learn is the print function.
|
Parameters
|
Print Function
|
In programming, we often pass data and objects between different segements of our programs. For example, when you call a function, like print(), often you can pass values to that function for it to use in performing its tasks. These values that we pass are called parameters.
|
Precision
|
Data & Data Types
|
When we talk about numeric data types we often need to know the precision and scale of the data types. Precision means the number of significant number of digits possible in a value. Scale refers to the number of digits to the right of the decimal point. So, for example, 12345.67 has a precision of 7 and a scale of 2.
Why is this important? When we are setting up our programs to process data, we choose data types based on the values we expect we will need. So, for the age example above, we would most likely want to store that as an integer, that is with no decimal values. So, knowing that we will not store decial values, we choose the integer data type. We can also decide on reasonable range of values to expect in that data. If we prompted a user for their age and they entered 4592, which has a value much larger than known human age, we would want to reject that value as invalid. That's an example of applying knowledge of both the data we are working with combined with knowledge of what is available in Python to store values.
|
Projects
|
PyCharm IDE
|
A project in PyCharm (and most IDEs) is how we organize all of the files for a programming project. Creating a new project in PyCharm will create a set of folders for your project. When we develop software, we often create many code files, as well as fiels for data, configuration, etc. All of the files for your programming project will be stored in the project's set of folders, which makes it easy to manage, to backup and to share.
|
Repetition
|
PyCharm IDE
|
(a.k.a. looping) a common programming construct in which we repeat statements either a set number of times or until a particular condition occurs. The most common constructs for repetition are the while loop and the for loop.
|
Scale
|
Data & Data Types
|
When we talk about numeric data types we often need to know the precision and scale of the data types. Precision means the number of significant number of digits possible in a value. Scale refers to the number of digits to the right of the decimal point. So, for example, 12345.67 has a precision of 7 and a scale of 2.
Why is this important? When we are setting up our programs to process data, we choose data types based on the values we expect we will need. So, for the age example above, we would most likely want to store that as an integer, that is with no decimal values. So, knowing that we will not store decial values, we choose the integer data type. We can also decide on reasonable range of values to expect in that data. If we prompted a user for their age and they entered 4592, which has a value much larger than known human age, we would want to reject that value as invalid. That's an example of applying knowledge of both the data we are working with combined with knowledge of what is available in Python to store values.
|
Truth Tables
|
Booleans
|
Truth Tables: are tables of rows and columns used to evaluate compound True/False conditions (often called propositions) of a logical problem. The table is intended to compare all possible propositions (combinations) that make up resulting values of the problem. We use truth tables in programming to aid in designing solutions.
|