1/81
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Expression
a combination of items, like variables, literals, operators, and parentheses
Literal
a fixed value used in code, such as a number, string, or boolean that is directly written in the program
Operator
a symbol that tells the interpreter to perform specific mathematical, logical, or relational operations on operands.
value
a specific piece of data that can be stored in a variable or used in an expression, such as a number, string
float
a data type in Python used to represent real numbers that include a decimal point. It can represent both positive and negative numbers.
integer
a data type in Python used to represent whole numbers, both positive and negative, without any fractional component.
string
a sequence of characters that represents textual data like a person's name, a location, or a message to the user. A string can be created in various ways, such as from user input or from being defined in a program's source code.
evaluates
describes the process of determining the value of an expression or code in Python, executing it to produce a result.
precedence rules
the guidelines that determine the order in which different operations are evaluated in an expression. They dictate which operations take priority over others, affecting how the expression is calculated. These rules influence the outcome of expressions involving multiple operators, ensuring correct and expected calculations.
unary minus
an operator indicating that a number should be treated as negative, effectively changing its sign. In Python, this operator is often applied to numeric types for arithmetic operations. It allows the negation of a value, making it useful for expressions requiring negative numbers.
compound operators
operators that combine an arithmetic operation with assignment, allowing for more concise code. An example is +=
, which adds a value to a variable and assigns the result back to that variable.
function
a block of reusable code that performs a specific task. Functions help organize and structure code, allowing for modular programming by enabling the grouping of related operations under a single name and invoking them as needed.
function definition
a description of the input parameters and outputs for a specific function, outlining its purpose and usage within a program.
function call
the action of invoking a defined function in a program by specifying its name and providing the necessary arguments. This executes the code within the function and returns any output.
return statement
a special statement in a function that exits the function and optionally sends a value back to the caller, allowing the function to produce output.
None
a keyword in Python used to exit a function and return a value to the caller, enabling the function to produce output based on its operations.
OR
special keyword that indicates no value
parameter
a function input specified in a function definition
argument
a value provided to a function's parameter during a function call
assignment
the process of assigning a value to a variable in Python, allowing the storage and retrieval of data
prompt
a message displayed to ask the user for input, often used in functions to guide user interaction
interpreter
a program that reads and executes Python code line by line, allowing for immediate feedback and debugging.
code
a common word for the textual representation of a program
variable
a named storage location in memory that can hold different values during program execution, allowing for data manipulation and retrieval.
new line character
a special character used in programming to indicate the end of a line and the start of a new line, typically represented as '\n' in Python.
escape sequence
a series of characters that represent a special character in a string, allowing for formatting and control sequences, such as '\n' for new lines and '\t' for tabs in Python.
whitespace
any character or sequence of characters that represent horizontal or vertical space in text, such as spaces, tabs, and new lines, which can impact the formatting of strings in Python.
type
a classification that defines the nature of data in Python, determining how it can be used, such as integers, strings, lists, and more.
input()
a built-in function in Python that receives input from the user as a string, allowing for interactive user communication during program execution.
syntax error
an error that occurs when the code does not conform to the rules of Python's syntax, preventing the program from executing properly.
logic error
a mistake in a program that produces incorrect or unexpected results due to flaws in the program's logic, rather than a syntax issue. a common type of error that does not stop program execution but leads to incorrect outcomes, often making it harder to identify and fix.
ValueError
|
TypeError
An operation uses incorrect types, which can occur if adding an integer to a string.
NameError
the program tries to use a variable that does not exist.
IndentionError
Occurs when the indentation of code blocks in Python is inconsistent or incorrect, leading to a syntax issue.
string literal
a string defined in the source code of a program by surrounding the text value with single or double quotes, like 'MARY' or "MARY".
sequence type
a type that orders a collection of objects into a sequence from first to last. A string's characters are ordered from the string's first letter to the last. A character's position in a string is called that character's index.
len()
built-in function can be used to find the length of a string (and any other sequence type like a list).
string concatenation
A program can add new characters to the end of a string in a process known
f-string
allows a programmer to create a string with placeholder expressions that are evaluated as the program executes.
replacement field
placeholder expression. as its value replaces the expression in the final output
format specification
inside a replacement, field allows a value's formatting in the string to be customized
presentation type
part of a format specification that determines how to represent a value in text form, such as an integer (4), a floating point (4.0), a fixed precision decimal (4.000), a percentage (4%), a binary (100), etc. A presentation type can be set in a replacement field by inserting a colon :
and providing one of the presentation type characters
Boolean value
a type that has just 2 values, true or false
inequality operator
!=
evaluates if left and right side are inequal or different
equality operator
==
evaluates if left and right side are equal
branch
sequence of statements that only executes under certain condition
if statement
An if statement executes a group of statements if an expression is true. The statements in a branch must be indented, typically four spaces.
if-else statement
An if-else statement executes one group of statements when an expression is true, and another group of statements when the expression is false.
can extend to if-elseif-else
multi-branch if else statements
An if-else statement can be extended to have three (or more) branches. Additional branches use the elif keyword, which means "else if". Each branch's expression is checked in sequence.
As soon as one branch's expression is found to be True, that branch's statement executes (and no subsequent branch is considered). If no expression is True, the else branch executes.
relational operators
checks how one operand's value relates to another, such as being greater than.
operator chaining
For example, a < b < c
determines whether b is greater-than a but less-than c. Chaining performs comparisons left to right, evaluating a < b first. If the result is True, then b < c is evaluated next. If the result of the first comparison a < b is False, then there is no need to continue evaluating the rest of the expression. Note that a is not compared to c.
loop
program construct that repeatedly loops the execution of a block of code as long as the expression is true. IF the expression is false, it proceeds past the loop.
iteration
each time through the loop’s statement
while loop
Runs a block of code repeatedly while the condition is true. when the condition is false, the loop ends.
sentinel value
value that cause a loop to end, user controls when the loop ends, distinguishing it from other loops
infinite loop
loop that never stops running because it’s condition is always true
docstring
A special type of comment in Python used to document functions, classes, and modules. It describes their purpose and usage, making code easier to understand.
It is enclosed in triple quotes and can be accessed by the help function.
loop variable
a variable that controls the iteration of a loop, usually updated in each cycle.
can be used for counting
floor division operator
//
A Python operator that divides two numbers and returns the largest integer less than or equal to the result.
modulo
A Python operator that returns the remainder of the division of two numbers.
escape sequence
A special sequence of characters in Python, starting with a backslash (), that allows the inclusion of characters in strings that are otherwise difficult to type or represent such as newlines or tabs.
ex: \n =new line or \t =tab
raw string
A string in Python that treats backslashes as literal characters and does not interpret escape sequences. It is defined by prefixing the string with an 'r'
ord()
A built-in Python function that returns the integer representing the Unicode code point of a given character.
chr()
A built-in Python function that returns the character corresponding to a given integer representing a Unicode code point.
logic operators
are used to combine conditional statements in Python, evaluating to Boolean values.
AND OR NOT
logical AND, logical OR, logical NOT
are operators that combine conditional statements, returning True or False based on the evaluation.
Boolean AND Boolean OR Boolean NOT
are logical operators that evaluate expressions to return Boolean values, aiding in decision-making processes in Python.
conditional expression
is an expression that evaluates to a value based on a condition, typically using the syntax x if condition else y
in Python.
ternary expression
is another term for a conditional expression in Python, allowing for inline conditional evaluations with a concise syntax.
container
construct used to group related values together and contains references to other objects instead of data
is a data structure
list
is created by surrounding sequence of variables or literal with brackets [ ], lists are mutable
also a sequence type, meaning contained items are ordered by position in the list, known as list’s index -starting w/ zero
element
a list item
method
instructs an object to perform some action and is specified by providing the object name followed by a "." symbol and then the method name.
append()
list method is used to add new elements to a listat the end of the list.
ex: my_list.append(“abc”)
pop()
list method is used to remove
list.pop(i)
: Removes the element at index i from list. Ex: my_list.pop(1)
remove()
list method is used to remove the first occurrence of a specified value from the list.
list.remove(v)
: Removes the first element whose value matches v. Ex: my_list.remove("abc")
sequence-type methods
functions built into the Python language definitions of sequence types like lists and strings. All sequence-type objects have associated methods that typically alter or return some information about the object.
sequence-type functions
functions built into the Python language that take sequences like lists or strings as arguments and operate on the given sequences. They do not require an object or "." dot notation.Ex: len(my_list)
retrieves the length of a sequence.These functions operate on sequences without needing to call them on sequence objects.
Tuple
a type of immutable sequence in Python, which can hold a collection of objects. Tuples are defined by enclosing elements in parentheses, allowing for mixed data types and can be indexed.
Named tuple
allows the programmer to define a new simple data type that consists of named attributes. A Car
named tuple with fields like Car.price
and Car.horsepower
would more clearly represent a car object than a list with index positions correlating to some attributes.
set
an unordered collection of unique elements. A set has the following properties:
Elements are unordered: Elements in the set do not have a position or index.
Elements are unique: No elements in the set share the same value.
Sets can be modified (mutable) with .add(), .pop()-random element, and .remove()-given value, .clear()