By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.
str() A Python data type that holds a string of characters.
int() A native type representing the integers, which are positive whole numbers and their opposites.
float() A native type representing rational numbers to limited precision.
boolean A single value of either TRUE or FALSE
indexing Finding the position of a character in a string or a string in a list, uses [ ]. Always starts at 0.
Slicing Using indexing to single out a single "piece" of a string or list. [1:2], [:2], [1:]
Assignment Setting the value of a variable.
Comparison Operators Symbols that evaluate each value to determine if it is the same (=), greater than (>), less than (<), or in between a range of values as specified by the criteria.
logical operators And, or, not... in Python also is and in ... assist in setting up proper logic in a program, basic Boolean logic is performed when executing.
Arithmetic Mathematics performed by the executor, uses /+*%
Identity operator Simply "is", determines if one variable is the other.
Containment operator Simply "in", determines if a variable is located in a string or list.
if statement A line that determines whether or not you run a certain chunk of code
elif statement An optional construction in an if-clause that allows you to evaluate multiple alternate conditions.
else statement The code to be executed if the if-condition evaluates to False in an if-structure.
nested conditional A conditional statement that appears in one of the branches of another conditional statement.
Compound Conditional A conditional with one or more logical operators used to incorporate several logical expressions.
while loop A control flow statement that allows code to be executed repeatedly as long as its condition remains True.
for loop Loops that have a predetermined beginning, end, and increment (step interval).
break When read by the prompter, causes the loop or function to be exited.
Continue When read by the prompter, causes the current iteration of a loop to be skipped.
Pass A placeholder for a conditional.
nested loop A loop inside the body of another loop.
.open() Opens a file.
.close() Closes a file.
"r" The syntax for opening a file in read mode.
"w" The syntax for opening a file in write mode.
"a" The syntax for opening a file in append mode.
os.path.isfile(path) Determines if a file exists.
os.remove("test.txt") Deletes the file expressed.
with statement Allows statements like try/except to be reusable.
f Put in front of a string that is to be printed to format the variable value into the variable keyword's place.
# This signifies a one line comment.
""" """ This signifies a multiline comment w/ the comment between the sets of quotations.
Indentation to move one or more lines inward from the margins. Signifies that that line acts under the loop or statement.
pydoc Python documentation. Access through Powershell via "python -m pydoc [method]"
Calling a function Calling a function is using a function in your program. To call a function you use the function name followed by parantheses that contain any arguments and then a semicolon. To call the function calculate with the arguments 2 and 3, the code would look like this: calculate(2,3); | When a function is called all the lines of code or actions that define a function will be run.
Default values If the operator does not assign values in computer operations, the computer automatically can assign. Parameters that have default values must be inputted last in the function definition.
Return command Sends a value back to the calling method. Can only return one value.
Def used to create a new user defined function
syntax error An error in a program that makes it impossible to parse — and therefore impossible to interpret. Caused by errors in typing the code.
logic error An error in a program that makes it do something other than what the programmer intended.
runtime error An error that occurs when the program is run using certain sets of data that result in some illegal operation, such as dividing by zero.
try statement contains a block of code. If an error occurs during execution, the try statement catches the exception, preventing a crash.
except statement In the case of the code in the try statement failing, this provides an error message created by the programmer.
else statement If the try statement works, this runs.
finally statement The final statement in exception-handling code, which executes regardless of whether its associated try block throws an exception.
raise provide the user with the error in a try/except statement.
math A built in module in python that is called by inputting the command import math
datetime Imported from the datetime library. | datetime.now() | [ Gives date and time to programs ]
.io Read and open files.
.sys Deals with system files, such as errors.
.os Edit and use files and folders.
os.path Operating system path module: allows many functions to occur on a specified path. Ex: os.path exists will return a true or false if a file does or doesn't exist
random module that imports the ability to create random sequences.
Join 4M+ learners. Unlock unlimited quizzes, wrong-answer tracking, flashcards + reminders, study guides, and 1-on-1 challenges.