1/43
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
\ n
New line character
\ t
Tab character
Boolean
A value that is either true or false
Character
A single character
Comments
Describes what the program does and how you understand it
Concatenation
Combining two strings together
Counter
A variable that counts during a loop
Decrement
Decreases the value of a variable
Dictionary
A list containing a key and a value
Hard drive
Where everything is stored
IDE
Integrated Development Environment, where software is developed and run
In
A keyword used to check membership in a sequence
Increment
Increases the value of a variable
Index
The position within a string, list, set, or tuple
Infinite loop
A loop that runs endlessly until stopped by the user
Integer
A whole number
Key words
Reserved words used as commands in the language
Key Values
Assigning a value to a key in a dictionary
Len()
Finds the length of a collection
List
A variable that holds multiple values
Logical Operators
Operators like And, Or, and Not
RAM
Random Access Memory, short-term storage used while a program runs
Relational Operators
Operators like <, >, <=, >=, ==
String
A sequence of characters (word or phrase)
Tuple
A collection that cannot be changed after creation
Math Operators
Operators like +, -, /, *, **, and %
Float
A variable that can store decimal numbers
Rules for variable assignment
Use camelCase, avoid reserved keywords, no spaces, and don’t start with a number
Difference between list and tuple (1)
A list is defined with square brackets [], while a tuple is defined with parentheses ()
Difference between list and tuple (2)
Tuples can hold all types of data, whereas lists can hold only one type of data. Tuples are immutable (cannot be modified), but lists are mutable.
readline()
Reads a single line from a file
Random.randint() vs Random.randrange()
Random.randint() includes the stop value, while Random.randrange() does not
While loop vs For loop
A for loop iterates a specific number of times and automatically increments, while a while loop repeats until a condition is met, often using a sentinel
Assignment operators (+=, -=)
Modify the variable’s value by performing an operation and reassigning it to itself
Four parts of every loop
Counter, sentinel, comparison statement, and increment/check for new input
Colon in Python
Indicates that the following code block is part of a function or control structure
Global Scope
Variables declared outside functions, accessible throughout the program
Local Scope
Variables declared inside a function, accessible only within that function
Block Scope
A variable that exists only inside a specific block of code like a loop
Sending parameters to a function
Place variables inside the function’s parentheses
Returning a value from a function
Use the return statement, followed by the value to return, and assign it to a variable
Why should you comment your code?
Comments help explain what the code does, both for yourself and others who read it
Ways to access a text file
Append (modify content), Read (retrieve content), Write (create or overwrite content)
What do you do when you're finished with a file?
Close the file to prevent data corruption