By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.
%a abbreviated weekday name (ex. sun, mon, tues)
%A full weekday name (ex. sunday, monday, tuesday)
%d day of the month as a zero padded decimal (ex. 01, 02, 03)
%b abbreviated month name (ex. jan, feb, dec)
%B full month name (ex. january, february, december)
%m month as a zero padded decimal (ex. 01, 02, 03)
%y 2 decimal year number (without century) (ex. 00, 01, 99)
%Y 4 decimal year number (with century) (ex. 1900, 1999, 2015)
%H hour in 24-hour clock (zero-padded) (ex. 00, 01, 23)
%I hour in 12-hour clock (zero-padded) (ex. 00, 01, 12)
%p am or pm (ex. AM, PM)
%M minutes as zero-padded decimal (ex. 00, 01, 59)
%S seconds as zero-padded decimal (ex. 00, 01, 59)
when declaring variables in python, a data type must be specified false
python makes the distinction between integers and floating variables true
when setting a boolean variable, the value must start with a capital letter true
"last-name" and "last name" are improper variable name declaration? true
how would you illiterate through a list in python for in loop
how do you add a string to a list? .append()
how do you sort a list of strings? .sort()
when using an if/elif/else statement, declaring a function, while loop, for in loop, etc. what is needed at the end? :
what is the correct way to find the index? print(listName[:])
how do you step in an index? print(listName[::])
how do you go backwards in an index? [-1] or any negative number
is this an incorrect syntax? onSale=true yes
a=5 b=5.5 c=7 a!=int(b)? false
a=5 b=5.5 c=7 a<=b true
a=5 b=5.5 c=7 c>=int(b) true
in python, this symbol does what when doing calculations? / will divide the two numbers
in python, this symbol does what when doing calculations? ^ raise to the number power
in python, this symbol does what when doing calculations? mod not used for calculations in python but in other languages it is used
in python, this symbol means what when doing calculations? % returns a modulus, a remainder
a=5 b=3 b=a a==b? true
a=5 b=3 b=a a is b? true
a=5 b=3 b=a b==3 false
how to check if a word is in a string in
how do you add a string to empty strings +1
in range and index the stop number is included? false
does index 1 start at the 2nd character? yes
does len 1 start at the first character? yes
how do you find the length of a string len()
pass placeholder for a conditional result
break exists a loop
while starts a loop
continue skips a turn in a loop
is def need before defining a function? yes. def function(parameters):
return returns variable
to call a function functionName(parameters)
make a comment #
must indent in loops and functions true
\ continues statement on next line
\n print a new line
\t insert a tab
\\ use \ character
.read() reads the entire contents of the file and stored it until printed
.close() closes file/frees up memory
.readline() prints the first line of the text file being opened
.readlines() prints text file contents as a list
input allows for user input
f tells python that the following text will be formatted text and the text in {} should refer to a variable
\ escape character
% used for formatting purposes
help() lists available python commands and show information on these command when an individual command is entered/gives user access to python commands after typing command name - when using python in command line environment
else shows is the try was successful
except error message
finally at the end
in error handling, the else clause is optional and must come right after the except clause the statement is correct as is
raise keyword - will show an actual error message should an error occur
import math for math functions
ceil rounds up
floor rounds down
trunc gets rid of decimal to reveal whole number
sqrt squareroot
() in math parentheses
in math exponentiation
* in math multiplication
/ in math division
// in math integer division
% in math modulo, remainder
+ in math addition
- in math subtraction
, concatenation with strings
+ concatenation with numbers
.today() today's date
io used to read and wrote to files
sys can display error messages that would not otherwise show
os allows python code to create folders
os.path allows python code to find specific files and folders
datetime *A date and time combination. Format: YYYY-MM-DD HH:MI:SS Note: The supported range is from '1000-01-01 00:00:00' to '9999-12-31 23:59:59'
import to import attributes like math, random, date, time, datetime, etc.
from_import_ datetime, randint, random
strptime() converts string into date format
strftime() formats a date
pydoc is a self contained executable that can be run from a command-line prompt false
pydoc generates documentation on python modules true
the proper syntax for pydoc is python -m pydoc module where module represents the name of the python module true
runtime error not caused by bad syntax or logic
except used if error should or does occur
"False" string
False Boolean
1 integer
1.0 float
!= not equal to
when variables are declared, a data type must be specified false
Join 4M+ learners. Unlock unlimited quizzes, wrong-answer tracking, flashcards + reminders, study guides, and 1-on-1 challenges.