Python
Invalid names
42c (doesn't start with a letter), hi there (has a space), cat$ (has a symbol other than a letter or digit), num cars, 3rd_place, and third_place! are all
equality operator
A common error is to use an identity operator in place of an
comprising substrings
A common programming task is to break a large string down into the
Code
A common word for the textual representation of a program and hence programming is also called coding.
Python interpreter
A computer program that executes code written in the Python programming language. Can load and execute code saved in files
arbitrary argument list tuple.
A function definition can include a *args parameter that collects optional positional parameters into an
Called
A function definition must be evaluated by the interpreter before the function can be
Parameter
A function input specified in a function definition. Ex: A pizza area function might have diameter as an input.
append the unit of measure, for example, instead of temperature, use temperature_celsius
A good practice when dealing with scientific or engineering names is to
use all lowercase letters and to place underscores between words
A good practice when naming variables is to
end=' '
A keyword parameter for the print() function that causes the function to NOT add a newline at the end of the string.
def
A keyword used to create new functions.
Dynamically Typed
A language is blank if the type is associated with run-time values, and not names variables/fields/etc.
Bug
A logic error
Function
A named series of statements.
variables to a specific scope
A namespace is how the Python interpreter restricts
newline
A new output line starts after each print statement. A print statement's default behavior is to automatically end with a
Unpacking
A process that performs multiple assignments at once.
Interpreter
A program that executes computer code. A programmer can write Python code in a file, and then provide that file to the
the user-defined function that gets input is not completed.
A program that requires user input should not execute if
Python interpreter
A program that runs on a computer, just like an Internet browser or a text editor
locals() and globals()
A programmer can examine the names in the current local and global namespace by using these built in functions
passing a copy of the object to a function.
A programmer can protect mutable arguments from unwanted changes by
tabs and spaces
A programmer should never mix
whether or not calling the unwritten function is a valid operation.
A programmer writing a function stub should consider
Line
A row of text
Line
A row of text.
String
A sequence of characters, like the text MARY, that can be stored in a variable.
Code block
A series of statements that are grouped together.
Digit
A space character is not a
String literal
A string value specified in the source code of a program. A programmer creates a string literal by surrounding text with single or double quotes, such as 'MARY' or "MARY".
Boolean
A type that has just two values: True or False.
Sequence type
A type that specifies a collection of objects ordered from left to right
Identity
A unique identifier that describes the object
Argument
A value provided to a function's parameter during a function call. Ex: A pizza area function might be called as print_pizza_area(12.0) or as print_pizza_area(16.0).
Global variable
A variable defined outside of a function. Its scope extends from assignment to the end of the file and can be accessed inside of functions.
write that variable
A variable must be marked as global only if the function needs to
Scope
A variable or function object is only visible to part of a program, known as the object's
\a
ASCII Bell -may cause receiving device to emit a bell or warning of some kind
crash
Abrupt and unintended termination of a program is often called a
a dictionary containing "extra" arguments not defined in the function definition
Adding a final function parameter of **kwargs creates
the same dictionary object
Adding an element to a dictionary argument in a function might affect variables outside the function that reference
set1.update(set2)
Adds the elements in set2 to set1.
set.add(value)
Adds value into the set.
Keyword arguments or Named arguments
Allow arguments to map to parameters by name, instead of implicitly by position in the argument list.
Keyword arguments
Allow arguments to map to parameters by name, instead of implicitly by position in the argument list. Provide a bit of clarity to potentially confusing function calls
Identifier
Also called a name, a sequence of letters (a-z, A-Z), underscores (_), and digits (0-9), and must start with a letter or an underscore
logic error
An error in the algorithm used to solve a problem.
syntax error
An error that occurs when one violates a programming language's rules on how symbols can be combined to create a program.
line
An example of a syntax error is to put multiple prints on the same
ValueError
An invalid value is used - can occur if giving letters to int().
Function call
An invocation of the function's name, causing the function's statements to execute.
changes
An object's type never
TypeError
An operation uses incorrect types - can occur if adding an integer to a string.
Set
An unordered collection of unique elements
Static-typed languages
Analyze the source code when compiled to find errors.
leaving the original argument object unchanged.
Any modification to an immutable object results in the creation of a new object in the function's local scope, thus
any other variables in the program that reference the same object.
Any operation like adding elements to a container or sorting a list that is performed within a function will also affect
whitespace
Any space, tab, or newline is called
list.append(obj)
Appends object obj to list
list.extend(seq)
Appends the contents of seq to list
the likelihood of introducing bugs because the user entered an unexpected string value
Applying transformations immediately limits
Python programs
Are developed by writing code in files.
Function return statements
Are limited to returning only one value.
Commas, spaces, and periods
Are not cased
False
Are the following expressions true or false? '1 2 3 4 5'.isdigit() 'HTTPS://google.com'.isalnum()
True
Are the following expressions true or false? 'HTTPS://google.com'.startswith('HTTP') '\n \n'.isspace() 'LINCOLN, ABRAHAM'.isupper()
Objects
Are used to represent everything in a Python program, including integers, strings, functions, lists, etc
find() and rfind()
Are useful only for cases where a programmer needs to know the exact location of the character or substring in the string.
Pass-by-assignment
Arguments to functions are passed by object reference, a concept known in Python as
mistakes
As soon as a person begins trying to program, that person will make
local namespace
Assignments in a function only affect the
\\
Backslash. Used to print a backslash character
Static typing
C, C++, and Java use this. Requires the programmer to define the type of every variable and every function parameter in a program's source code.
help() function
Can aid a programmer by providing them with all the documentation associated with an object.
Error messages
Can be confusing, or not particularly helpful
Mutable argument objects
Can be modified in-place inside a function, and those changes will affect any variable that references the same object
Multi-line docstrings
Can be used for more complicated functions to describe the function arguments, and should use consistent indentation for each line, separating the ending triple-quotes by a blank line
A large program
Can contain many functions with a wide variety of uses.
Variable names
Can obtain only numbers, letters, and an underscore. Cannot start with a number.
better-organized code, reduced development time, and even to code with fewer bugs.
Capturing high-level behavior first may lead to
\r
Carriage return. Position the screen cursor to the beginning of the current line; do not advance to the next line.
cannot be used as names
Certain words like "and" or "True"
conditional execution
Check for certain conditions and execute the appropriate code.
Dynamic-typed languages
Check for errors as the program executes.
Relational operator
Checks how one operand's value relates to another, like being greater than.
Compiler
Checks the types of variables when the code is compiled to find invalid operations.
set.clear()
Clears all elements from the set.
Copying-and-pasting code
Common error that can lead to common errors if all necessary changes are not made to the pasted code.
If-elseif-else branches
Commonly used when a programmer wishes to take one of multiple (three or more) branches
Function definition
Consists of the new function's name and a block of statements. Ex: def print_pizza_area():. An indented block of statements follows the definition.
Global scope
Contains all globally defined names outside of any functions
Built-in scope
Contains all of the built-in names of Python, such as int(), str(), list(), range(), etc
describe an item's purpose
Create meaningful names that
The interpreter
Creates and manipulates objects as needed to run the Python code
A function call
Creates new local variables that reference the existing argument objects
garbage collection
Deleting unused objects helps to keep the memory of the computer less utilized and is an automatic process called
'#'
Denote comments, which are optional but can be used to explain portions of code to a human reader.
type
Determines how a value can behave. Examples include strings and integers.
Dynamic typing
Determines the type of objects as a program executes
output
Display data on the screen or send data to a file or other device.
Interactive interpreter
Displays a prompt (">>>") that indicates the interpreter is ready to accept code. A powerful calculator. A program that allows the user to execute one line of code at a time. Useful for simple operations or programs consisting of only a few lines.
print()
Displays variables or expression values.
Programmers
Do not explicitly create objects
No
Does reading a global variable require a global statement?
No, as 'Jo' is a substring of 'Kay, Jo', but 'Kay, Jo' is not a substring of 'Jo'
Does reversing the arguments work?
\"
Double quote. Used to print a double quote character.
value, type, and identity
Each Python object has three defining properties
Number
Each element of a sequence is assigned a
new line
Each print statement will output on a
unwieldy for any program spanning more than a few lines.
Entering code line-by-line into the interpreter quickly becomes
\n
Escape character for new line
\t
Escape character for tab. Horizontal tab. Moves the screen cursor to the next tab stop
Function object
Evaluating the function definition binds the function name to a new
Python 3 reserved keywords
False, class, finally, is, raise, None, continue, for, lambda, return, True, def, from, nonlocal, try, and, del, global
sum(list)
Find the sum of all elements of a list (numbers only)
len(set)
Finds the length (number of elements) of the set.
print("Dogs: ", num_dogs)
Fix the following code. print("Dogs: " num_dogs)
print('Woof!')
Fix the following code. print('Woof!")
print('Woof!')
Fix the following code. print(Woof!)
print(num_dogs)
Fix the following code. print(num_dogs).
user-input
For easy comparison, trip(), lower(), and upper() standardize
Common error
Forgetting to return a value from a function is a
Function stubs
Function definitions whose statements haven't been written yet. assist with the incremental development process
input
Get data from the keyboard, a file, or some other device.
Programmers
Give names to various items, such as variables and also functions
help(value)
Gives information about what you can do with a value.
comparing values
Good practice is to always use the equality operator== when
reading in data (such as input), as opposed to later in the program
Good practice when reading user-entered strings is to apply transformations when
If-else structure
Has two branches: The first branch is taken if an expression is true, else the other branch is taken
Scopes and namespaces
Help explain how multiple variables can share the same name, yet have different values
that name is visible and a programmer can use it in an expression
If a namespace contains a name at a specific location in the code, then
'Bog'
If my_str is 'Boggle', then my_str[0:3] yields string
the shorter string is considered less than the longer string.
If one string is shorter than the other with all corresponding characters equal, then
a character or substring is contained in the string
If the exact position is not important, than the in membership operator should be used to check if
the interpreter generates a NameError
If the name cannot be found in any namespace,
limited to inside the function
If the object is immutable, such as a string or integer, then the modification is
outside the scope of the function
If the object is mutable, then in-place modification of the object can be seen
empty string for each such occurrence.
If the split string starts or ends with the separator, or if two consecutive separators exist, then the resulting list will contain an
after the first assignment of the variable until the end of the function.
In fact, because a variable's name does not exist until bound to an object, the variable's scope is actually limited to
NotImplementedError
Indicates that the function is not implemented and causes the program to stop execution.
mutability
Indicates whether the object's value is allowed to be changed. The type of an object also determines the object's
6th character in the string.
Indices start at 0, so index 5 is a reference to the
Prompt
Informs the programmer that the interpreter is ready to accept commands.
list.insert(index, obj)
Inserts object obj into list at ann offset index
Python programs
Instead of displaying a web page or creating a document, the purpose of the interpreter is to run
immutable
Integers and strings are
IDLE
Integrated Development Environment. Built into python. Can run python statements and programs. Very primitive. Likely to crash.
Invalid
Is the following assignment statement valid or invalid? x + y = y + x
Valid
Is the following assignment statement valid or invalid? x = 1
Valid
Is the following assignment statement valid or invalid? x = y
Invalid
Is the following assignment statement valid or invalid? x + 1 = 3
Valid
Is the following assignment statement valid or invalid? x = y + 2
A keyword argument
Is used for any function containing more than approximately 4 arguments, and can be mixed with positional arguments, provided that the keyword arguments come last.
Correct
Just because the program loads and executes does not mean that the program is
Variables
Location in memory where value can be stored. Can be integers, strings, or doubles
Function stubs
Mainly help a programmer capture correct high-level behavior before getting distracted by low-level details, and may lead to better organized programs, and may shorten development time too.
various words' roles
Many code editors color certain words, as in the below program, to assist a human reader in understanding
Namespace
Maps names to objects, and is used by the python interpreter to track all of the objects in a program.
Functions
May cause slightly slower execution, but offer improved readability.
Case sensitive
Means upper- and lowercase letters differ
List
Most flexible data type available in Python, which can be written as a list of comma-separated values (items) between square brackets. Items in a list need not all have the same type.
Slice notation
Multiple consecutive characters can be read using
Global statement
Must be used to change the value of a global variable inside of a function. Reading a global variable does not require a
Python has special usages for double underscore names
Names that start and end with double underscores (for example, __init__) are allowed but should be avoided because
make scope work
Namespaces are used to
colon
New code blocks may only begin after a statement that ends with a
Comments
Often ignored and not required in a program, but still helpful in explaining code to a reader of the program.
whitespace, including newlines and spaces.
Omitting the arguments to split() splits on every
pass a copy of the object as the argument instead
One method to avoid unwanted changes is to
identifier
Only one object at any time may have a particular
indexing, slicing, adding, multiplying, and checking for membership
Operations you can do with all sequence types include
the original object from being modified.
Passing a copy prevents
the readability of code
Passing functions as arguments can sometimes improve
Computation
Perform basic arithmetic operations like addition and multiplication.
repetition
Perform some action repeatedly, usually with some variation.
Pass keyword
Performs no operation except to act as a placeholder for a required statement.
Dynamically Typed Languages
Perl, Ruby, Python, PHP
print('Halt!', end=' ') print('No access!')
Prints output on the same line
Incremental development
Process by which programs are typically written. When a small amount of code is written and tested, then a small amount more (an incremental amount) is written and tested, and so on.
Statement
Program instruction
OverflowError
Raised when a calculation exceeds maximum limit for a numeric type.
String
Reading from input always results in this type
name = input().strip().lower()
Reads in the user input, strips all whitespace, and changes all the characters to lowercase.
Polymorphism
Refers to how an operation depends on the involved object types. Used by C, C++, and Java
Redundancy
Refers to writing the same code in multiple places.
set.pop()
Removes a random element from the set.
list.pop(obj=list[-1])
Removes and returns last object or obj from list
list.remove(obj)
Removes object obj from list
set.remove(value)
Removes value from the set. Raises KeyError if value is not found.
Objects
Represent a value and is automatically created by the interpreter when executing a line of code
Static typing
Requires the programmer to define the type of every variable and every function parameter in a program's source code. Allows for more flexibility in terms of the code that a programmer can write, but at the expense of potentially introducing more bugs, since there is no compilation process by which types can be checked
isupper()
Return True if all cased characters are uppercase letters.
isspace()
Return True if all characters are whitespace.
endswith(x)
Return True if the string ends with x.
startswith(x)
Return True if the string starts with x.
islower()
Returns True if all cased characters are lowercase letters.
isdigit()
Returns True if all characters are the numbers 0-9.
isalnum()
Returns True if all characters in the string are lowercase or uppercase letters, or the numbers 0-9.
title()
Returns a copy of the string as a title, with first letters of words capitalized.
lower()
Returns a copy of the string with all characters lowercased.
upper()
Returns a copy of the string with all characters uppercased.
replace(old, new)
Returns a copy of the string with all occurrences of the substring old replaced by the string new. The old and new arguments may be string variables or string literals.
strip()
Returns a copy of the string with leading and trailing whitespace removed.
capitalize()
Returns a copy of the string with the first character capitalized and the rest lowercased.
Locals()
Returns a dictionary of the names found in the local namespace.
set.union(set_a, set_b, set_c...)
Returns a new set containing all of the unique elements in all sets.
set.intersection(set_a, set_b, set_c...)
Returns a new set containing only the elements in common between set and all provided sets.
set_a.symmetric_difference(set_b)
Returns a set containing only elements that appear in exactly one of set_a or set_b
set.difference(set_a, set_b, set_c...)
Returns a set containing only the elements of set that are not found in any of the provided sets.
list.index(obj)
Returns the lowest index in list that obj appears
len()
Returns the number of elements in the list.
count(x)
Returns the number of times x occurs in the string.
find(x)
Returns the position of the first occurrence of item x in the string, else returns -1. x may be a string variable or string literal.
list.reverse()
Reverses objects of list in place
int()
Rounds a value down to the nearest whole integer.
rfind(x)
Same as find(x) but searches the string in reverse, returning the last occurrence in the string.
find(x, start)
Same as find(x), but begins the search at position start:
find(x, start, end)
Same as find(x, start), but stops the search at position end:
Floating-point types
Should be used to represent quantities that are measured, such as distances, temperatures, volumes, and weights.
Good variable names
Should describe the purpose of the variable, such as "temperature" or "age," rather than just "t" or "A."
early in the development of a larger program.
Simply doing nothing and returning nothing may be acceptable
my_str[start:end]
Slice notation has this form which creates a new string whose value mirrors the characters of my_str from indices start to end - 1
Stride
Slice notation provides for a third argument, which determines how much to increment the index after reading each element.
list.sort([func])
Sorts objects of list, use compare func if given
A docstring
Starts and ends with three consecutive quotation marks and is kept of a simple function as a single line, including the quotes.
Variables
Store values for later use. Used to refer to values saved in memory by the interpreter.
string literal
Text enclosed in quotes is known as a
slice
The Python interpreter creates a new string object for the
the name object
The Python interpreter creates a new string object from the string literal on the right, and compares the identity of the new object to
Duck typing
The act of determining if an object is of the correct type by simply checking if it has attributes or methods of the right names.
the existence of the argument on the left
The argument to the right of the operator is examined for
type
The built-in function type() prints the object's
Polymorphism
The function's behavior of being able to add together different types. It is an inherent part of the Python language.
def print_face()
The interpreter creates a new function object when this definition is evaluated.
syntax error
The interpreter will generate a message when encountering a
IndentationError
The lines of the program are not properly indented.
the function returns
The local namespace is removed when
Sequence
The most basic data structure in Python.
Interpreter
The names wage, hours, weeks, and salary are variables, which are named references to values stored by the
Precedence rules
The order in which operators are evaluated in an expression is known as
print()
The primary way to print output is to use this built-in function
Scope resolution
The process of searching for a name in the available namespaces is called
SyntaxError
The program contains invalid code that cannot be understood.
NameError
The program tries to use a variable that does not exist.
modifying an argument that is referenced elsewhere in the program may cause side effects outside of the function scope
The semantics of passing object references as arguments is important because
string argument
The separator can be changed by calling split() with a
a list of tokens
The split() string method splits a string into
4
The standard number of spaces to use for indentation is
joining a list of strings together to create a single string.
The string method join() performs the inverse operation of split() by
Code
The text that represents a computer program
behavior
The type of an object determines the object's supported
Type
The type of the object, such as integer or string
execute the code
The user types a line of Python code and presses the enter key to instruct the interpreter to
None
The value returned from a function without a return statement is always
Three
There are at least how many nested scopes active at any point in a program's execution?
Docstring
There should be no blank lines before or after a .
is, is not
These identity operators determine whether the two arguments are bound to the same object.
in, not in
These membership operators provide a simple method for detecting whether a specific substring exists in the string.
is not
This inverse identity operator gives the negated value of 'is'.
PEP 8
This lowercase and underscore convention for naming variables originates from the Python style guide,
split()
This method creates a new list, ordered from left to right, containing a new string for each sequence of characters located between '/' separators.
changed
Tupples' elements cannot be
Tuples
Typically surrounded with parentheses and behaves similar to a list
more complicated text or text that contains single quotes
Use double quotes for
shorter strings
Use single quotes for
Identity operator
Used to check whether two operands are bound to a single object.
Comparison
Uses the encoded values of characters ASCII/Unicode. May not behave intuitively for some situations.
split() and join()
Using these two methods together allows one to change the separators in a string.
Local scope
Usually refers to scope within the currently executing function, but is the same as global scope if no function is executing
Local variables
Variables declared within a function or procedure and so can be accessed only by the code within that function or procedure
Bytecode
What are functions compiled into when the function definition is evaluated by the interpreter?
Built-in, global, and local
What are the three nested scopes that are active at any point in a program's execution?
It removes the first element whose value is v.
What does list.remove(v): do?
7
What does my_str.find('!') return if my_str is 'Boo Hoo!'?
0
What does my_str.find('Boo') return if my_str is 'Boo Hoo!'?
1 (first occurrence only)
What does my_str.find('oo') return if my_str is 'Boo Hoo!'?
5
What does my_str.find('oo', 2) return if my_str is 'Boo Hoo!'?
-1 (not found)
What does my_str.find('oo', 2, 4) return if my_str is 'Boo Hoo!'?
It allows high-level behavior of the program to be captured before diving into details of each function
What is a benefit of a function stub?
Built in
What kind of function is str()?
Sequence, supporting len(), indexing, and other sequence type functions.
What type is touple?
binding the names in the parameter list to the passed arguments.
When a function is called, new local variables are created in the function's local namespace by
mutability of the argument object.
When a function modifies a parameter, whether or not that modification is seen outside the scope of the function depends on the
The local scope's namespace
When a name is referenced in code, what is the first scope checked?
Global
When a name is referenced in code, what is the second scope checked?
Built-in
When a name is referenced in code, what is the third scope checked?
Runtime error
When 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')
inside that function
When a variable is created inside a function, the variable's scope is limited to
Space
When split() is called with no argument, what character does the delimiter defaults to?
created for that function.
Whenever a function is called, a local namespace is
A user-defined function
Will likely be located in the global namespace.
input()
Will return the next string read from input.
Common errors
With practice a programmer becomes familiar with
append()
You can add to elements in a list with this method.
Separator
a character or sequence of characters that indicates where to split the string into tokens.
Printing of output to a screen
a common programming task.
float
a data type for floating-point numbers.
Python Enhancement Proposal
a document that outlines the basics of how to write Python code neatly and consistently
variable
a named item, such as x or num_people, used to hold a value.
floating-point number
a real number, like 98.6, 0.0001, or -666.667.
Token
a substring that forms a part of a larger string.
pass or print statements
allow a program to continue. The statement raise NotImplementedError causes the program to halt
Default argument
an argument that is passed automatically to a parameter if the argument is missing on the function call
Index
an integer matching to a specific position in a string's sequence of characters
or
and has precedence over
whitespace
any blank space or newline
Strings
are a sequence type, having characters ordered by index from left to right
Comparisons
are case-sensitive, so 'Apple' does not equal 'apple'.
NotImplementedError and the "raise" keyword
are explored elsewhere in material focusing on exceptions.
Syntax errors
are found before the program is ever run by the interpreter
User-defined functions
are in the global scope
assignment statement
assigns a variable with a value, such as x = 5.
The interpreter
assigns an object to a location somewhere in memory automatically
Any assignment statement
automatically creates (or modifies) a name in the local namespace only, even if the same name exists in a higher global or built-in scope by default.
Interpreter
begins by executing the first line of code at the top of the file, and continues until the end is reached.
join()
builds a new string from the list elements, adding the '.' separator between each pair of elements.
Valid names
c, cat, Cat, n1m1, short1, and _hello, numCars, num_cars1,_num_cars,___numcars2, third_place, output, and print_copy are all
String literal
can be surrounded by matching single or double quotes: 'Python rocks!' or "Python rocks!".
Set literal
can be written using curly braces { } with commas separating set elements.
Multiple namespaces
can each have the same name, and those names can even reference different objects.
Objects
can have more than one name bound to it, and every name is always bound to exactly one objects
A function
can only return a single object.
create new strings
capitalize(), lower(), upper(), strip(), and title() are methods to
equality operator
checks whether two operands' values are the same (==) or different (!=)
Expressions
code that return a value when evaluated; for example, the code wage * hours * weeks is an expression that computes a number.
Sparingly
global variables should be used
runtime error
halts the execution of the program
Each scope, such as global scope or a local function scope
has its own namespace
A namescape
is a normal Python dictionary whose keys are the names and whose values are the objects.
The Python interpreter
is able to detect syntax errors when the program is initially loaded, prior to actually executing any of the statements in the code
A new variable
is created by performing an assignment using the = symbol, such as salary = wage * hours * weeks, which creates a new variable called salary.
All code
is eventually compiled into bytecode before being executed
Code
is read more often than written, so having a consistent variable naming scheme helps to ensure that programmers can understand each other's code.
The scope
is the area of code where a name is visible
*
is used for multiplication.
Scientific notation
is useful for representing floating-point numbers that are much greater than or much less than 0, such as 6.02x1023.
floating-point literal
is written with the fractional part even if that fraction is 0, as in 1.0, 0.0, or 99.0
Frequent testing
leads to catching errors earlier, before multiple errors begin to interact with one another in strange ways.
Text in string literals
may have letters, numbers, spaces, or symbols like @ or #.
Incremental development
may involve more frequent testing, but ultimately leads to faster development of a program.
experienced programmers
may write more lines of code before testing
non-cased characters
methods islower() and isupper() ignore
Program
mostly consists of a series of statements, and each statement usually appears on its own line.
whitespace
newlines and spaces count as
Identity
normally refers to the memory address where the object is stored
Python 3 reserved keywords
not, while, as, elif, if, or, with, assert, else, import, pass, yield, break, except, in, print
Meaningful names
num_students_UCLA, diagonal_tv_size_inches, pi, num_guessed_jelly_beans, and user_guess_jelly_beans.
Overflow
occurs when a value is too large to be stored in the memory allocated by the interpreter
Name binding
occurs whenever an assignment statement is executed, as demonstrated below
Python
provides a built-in function id() that gives the value of an object's identity.
An individual character
read using an index surrounded by brackets
my_var = input()
reads a user-entered string into variable my_var without a prompt.
num_cars = input()
reads a user-entered string into variable num_cars?
Polymorphism
refers to how an operation depends on the involved object types
floating-point
refers to the decimal point being able to appear anywhere ("float") in the number.
list.count(obj)
returns count of how many times obj occurs in list
max()
returns the elements from the list with maximum value.
min()
returns the elements from the list with minimum value.
kwargs
short for keyword arguments. The keys of the dictionary are the parameter names specified in the function call.
Abbreviations
should only be used if widely understandable, as in tv_model or ios_app
e
stands for exponent.
most programmers
still run and test their syntax frequently.
Most coding activities
strictly require a student program's output to exactly match the expected output, including whitespace.
strings, lists and tuples
support slice notation.
Name binding
the process of associating names with interpreter objects
While loops
while (expression): statement
Language editors
will automatically color a program's reserved words
The error message
will report the number of the offending line, allowing the programmer to go back and fix the problem
Reserved words, or keywords, are
words that are part of the language, and thus, cannot be used as a programmer-defined name