1/49
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
program
A computer program consists of instructions executing one at a time.
Input
Input: A program receives data from a file, keyboard, touchscreen, network, etc.
Process
Process: A program performs computations on that data, such as adding two values like x + y.
Output
Output: A program puts that data somewhere, such as a file, screen, or network.
variables
Programs use variables to refer to data, like x.
computational thinking
In the information age, many people believe computational thinking, or creating a sequence of instructions to solve a problem, will become increasingly important for work and everyday life.
algorithm
A sequence of instructions that solves a problem is called an algorithm.
Python interpreter
The Python interpreter is a computer program that executes code written in the Python programming language.
interactive interpreter
An interactive interpreter is a program that allows the user to execute one line of code at a time.
Code
Code is a common word for the textual representation of a program (and hence programming is also called coding).
line
A line is a row of text.
prompt
The interactive interpreter displays a prompt (">>>") that indicates the interpreter is ready to accept code.
statement
A statement is a program instruction.
Expressions
Expressions are code that return a value when evaluated; for example, the code wage hours weeks is an expression that computes a number.
variables
The names wage, hours, weeks, and salary are variables, which are named references to values stored by the interpreter.
assignment
A new variable is created by performing an assignment using the = symbol.
print()
Print() function displays variables or expression values.
comments
Characters such as "#" denote comments, which are optional but can be used to explain portions of code to a human reader.
print()
The primary way to print output is to use the built-in function print().
string literal
Text enclosed in quotes is known as a string literal.
newline
A line break, known as a newline, is output after every print() statement.
newline character
Output can be moved to the next line by printing "\n", known as a newline character.
whitespace
Any space, tab, or newline is called whitespace.
input()
Reading input is achieved using the input() function.
string
The input obtained by input() is any text that a user typed, including numbers, letters, or special characters such as # or @. Such text in a computer program is called a string.
type
Strings and integers are each an example of a type; a type determines how a value can behave.
int()
If a string contains only numbers, like '123', then the int() function can be used to convert that string to the integer 123.
whitespace
Whitespace is any blank space or newline.
variable
In a program, a variable is a named item, such as x or num_people, that holds a value.
assignment statement
An assignment statement assigns a variable with a value, such as x = 5.
incrementing
Increasing a variable's value by 1, as in x = x + 1, is common and known as incrementing the variable.
identifier / name / underscores
An identifier, also called a name, is a sequence of letters (a-z, A-Z), underscores (_), and digits (0-9), and must start with a letter or an underscore.
case sensitive
Python is case sensitive, meaning uppercase and lowercase letters differ. Ex: "Cat" and "cat" are different.
Reserved words / keywords
Reserved words, or keywords, are words that are part of the language and cannot be used as a programmer-defined name.
PEP 8
PEP 8 (Python Enhancement Proposal) outlines the basics of how to write Python code neatly and consistently.
object
An object represents a value and is automatically created by the interpreter when executing a line of code. For example, executing x = 4 creates a new object to represent the value 4.
garbage collection
Deleting unused objects is an automatic process called garbage collection that frees memory space.
Name binding
Name binding is the process of associating names with interpreter objects. An object can have more than one name bound to it, and every name is always bound to exactly one object. Name binding occurs whenever an assignment statement is executed, as demonstrated below.
Value
Value: A value such as "20", "abcdef", or "55".
Type
Type: The type of the object, such as integer or string.
Identity
Identity: A unique identifier that describes the object.
type()
The built-in function type() returns the type of an object.
Mutability
Mutability indicates whether the object's value is allowed to be changed.
immutable
Integers and strings are immutable; meaning integer and string values cannot be changed.
id()
Python provides a built-in function id() that gives the value of an object's identity.
syntax error
One kind of mistake, a syntax error, violates a programming language's rules on how symbols can be combined to create a program.
runtime error
The program may have another kind of error called a runtime error, in which a program's syntax is correct but the program attempts an impossible operation, such as dividing by zero or multiplying strings together (like 'Hello' * 'ABC').
crash
Abrupt and unintended termination of a program is often called a crash of the program.
logic error
Such an error is known as a logic error, because the program is logically flawed.
bug
A logic error is often called a bug.