1/85
A comprehensive set of vocabulary flashcards based on lecture notes covering string manipulation, condition evaluation, and control structures in programming.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
String.expandtabs(integer)
Method to set the size of tab increments in a string.
Default increment for \t
8 spaces.
string.format(data)
Formats data of various types into a string.
Data types used with string.format()
Includes list, string, integer, float.
General format for string formatting
{index:how to format}.
Right justification in format specifier
Uses > symbol.
Center justification in format specifier
Uses ^ symbol.
Left justification in format specifier
Uses < symbol.
Example format string
"I have {0:>5d} {1:^7s}! ${2:<6.2f}".
Boolean conditions
Always result in True or False.
Relational operators
Operators that compare values: >,
Cannot compare
Numbers and strings.
String operators
Operators to check if a string exists in another string.
Character comparison
Compares strings character by character.
ASCII value of 'A'
65.
ASCII value of 'a'
97.
ord() function
Converts a character to its ASCII value.
chr() function
Converts an ASCII value to its character.
Logic behind logical operators
Create complex conditions resulting in True or False.
Operator precedence (high to low)
Math operators > Relational operators > Logical operators.
Logical AND operator
Only true if all conditions are true.
Logical OR operator
True if at least one condition is true.
Logical NOT operator
Inverts the truth value of a condition.
Boolean data type
Consists only of True and False.
isinstance() function
Checks the data type of a value.
stringA.startswith(stringB)
Checks if stringA starts with stringB.
stringA.endswith(stringB)
Checks if stringA ends with stringB.
string.isupper()
True if all letters are uppercase.
string.islower()
True if all letters are lowercase.
string.isdigit()
True if all characters are digits (0-9).
string.isalpha()
True if all characters are letters (upper or lower).
string.alnum()
True if all characters are letters or digits.
string.isspace()
True if all characters are whitespace.
if/else statement
Provides two options based on a condition.
Decision structure
Using conditions to control flow in a program.
Input example
Input commands to determine user menus (Lunch/Dinner).
Nested if/else statement
Any number of options can be evaluated.
while loops
Condition-controlled loops that execute as long as the condition is true.
Loop variable
Variable tested by the loop's condition.
Iteration
One execution of the loop body.
While loop general format
while condition(s): # code to repeat.
Example: Display blue 5 times.
Using a while loop with a count variable.
User-controlled loops
Loops that continue based on user input.
Input validation
Checking if user input is valid.
Sentinels in loops
Unique values indicating the loop should stop.
Break statement
Causes immediate exit from the loop.
Continue statement
Skips the current iteration of the loop.
sum of 1-5 using loop
Accumulates total using a while loop.
Display multiples of 3
Using a loop to print multiples between 1 and 50.
List data for formatting
Includes types: int, str, float, bool.
Input validation example
Asks for number 1-10, repeats if invalid.
Check for valid color input
Loops until 'RED' or 'BLUE' is entered.
False condition checks
Using logical operators in decision making.
Weight condition example
Checks if a pet is a dog and under 30 lbs.
Menu selection example
Determines food options based on user input.
General format for checking data type
isinstance(value, data type).
String starts and ends checks
Using string functions to verify position.
Returning boolean results
Evaluates conditions to return True/False.
Using formats for output
Standard format syntax for displaying data.
Character conversion to ASCII
Using ord() to get the numerical value.
Display formatted strings with variables
Incorporating data into strings via formatting.
Comparison of strings
Determined through ASCII values.
Character comparison using relational operators
To evaluate strings logically.
True and False in logical conditions
Utilizing Boolean logic.
Iterate through loop until condition fails
Using while for condition control.
Truth table for logical operators
Visualizing outcomes of AND, OR, NOT.
Data validation loops
Enforcing correct user input.
Accessing list elements via index
Using indices to retrieve formatted strings.
Predicting outcomes based on inputs
Using if-else structures to guide program flow.
Incrementing loop counters
Updating variables within loops gracefully.
Loop exit strategies
Implementing break and continue for control.
Using formatted strings for clarity
Enhancing readability through structured output.
Evaluating conditions with logical operators
Determining if conditions yield a boolean result.
Retrieving user's favorite colors
Through looping until a condition is met.
Ending a loop with a sentinel
Using specific values to stop iteration.
Displaying output effectively
Using print statements strategically.
Validating conditions with relational operators
Comparing values for decision making.
Creating complex conditions with logical operators
Combining multiple truth checks.
Memorizing ASCII table values
Knowing key character encodings.
String formatting with indices
Positioning data for clear output.
Representing data types in programming
Understanding int, str, float, and bool.
Defining conditions for execution paths
Structuring execution based on true/false outcomes.
Enforcing character case checks
Using isupper() and islower() methods.
Displaying conditional outputs
Using print structures within decision frameworks.
Retaining string integrity while manipulating
Ensuring strings maintain their value after checks.
Evaluating menu options via user input
Navigating choices based on what user selects.