ADV PROG DAY 4 Flashcards
- An object-oriented interpreted language, used throughout CNO mission areas for building CNO analysis tools and testing applications.
- An easy to learn programming language with decreased complexity, code-writing efficiency, limitless third-party libraries, and is available on most UNIX workstations.
python
display information on the monitor using Python.
automatically inserts a once the string has been displayed.
use a comma so output from two or more print statements can share the same line.
character.
\n
Tab character. The width of the tab is set by the terminal program, not the Python script, although it is typically eight spaces.
\t
Removes the meaning of the quote so it can be used as part of the string.
\” or \’
Backspace. Removes previous character from string.
\b
Attempts to convert the providedobject into a string.
str()
Attempts to convert the provided object into an integer.
int()
Attempts to convert the provided object into a float.
float()
Returns a sequenced list of elements from the object passed.
list()
Returns the data type of the object passed.
type()
Exits the Python script and returns a number to the terminal.
exit()
Displays the help page from the Python documents.
help()
Displays the number of elements in a set, like a list or a string.
len()
takes exactly what is typed and passes it back as a string. It does not interpret the user input.
Whether an integer value or a list is entered, its type is of string only.
raw_input( )
Returns a copy of the string with each letter capitalized.
string.upper( )
Returns a copy of the string with each letter in lowercase.
string.lower( )
Returns the first index position where the substring is found. Returns -1 if the substring is not found.
string.find()
Returns the string as a list delimited by the value passed as an argument, with a default of a whitespace.
string.split()
Returns the string with the last character removed.
string.strip()
Appends an object to the end of the list.
list.append()
Removes the first element from the list specified by the object value.
list.remove()
Deletes an element via index position.
list.pop()
Sorts all the items and updates the list at the same time.
list.sort()
Returns the index position of the first item located within the list equal to the object value.
list.index()
Equivalent to
==
Not Equivalent to
!=
Greater than
>
Greater than or equivalent to
> =
less than
less than or equivalent to
<=
is in the container
in
is not in the container
not in
Both conditions must be true
and
One or the other condition must be true
or
Invert the boolean value
not
allows programs to create, read, modify, and delete files within directories. Python uses open() to request a file handle from an OS. If the open()fails, an IOError exception is raised.
File I/O
Read mode
r
Write mode
w
Appends to the end of the file
a
Used in conjunction with any of the above modes to allow non-text files to be opened(e.g., image files like JPEGs or GIFs, audio files like MP3s,or binary document formats like Word or PDF)
b