ADV PROG DAY 5 Flashcards
Generates a list of every number between 0 and up to, but not including, the value specified by Stop. Start is defaulted to a value of 0 and step is defaulted to a value of 1.
range( Stop )
Generates a list of every number between the value specified by Start Generates a list of every number between the value specified by Start and up to, but not including, the value specified by Stop. Step is defaulted to a value of 1.and up to, but not including, the value specified by Stop. Step is defaulted to a value of 1.
range( Start, Stop )
Generates a list of every number between the value specified by Start and up to, but not including, the value specified by Stop, incrementing by the value specified by Step. (Step can be a negative value)
range( Start, Stop, Step )
Informs Python that the following block of code is a function definition.
def
A unique name by which a function is known. Following the same rules as variable naming (i.e., can contain letters, numbers, and underscores only, but may not begin with a number).
function_name
Functions can be written to allow from zero to 255 arguments. If a parameter contains an equal sign, the right-side is the default value in case no argument was passed. Each parameter must have a unique name.
parameters
The code to execute when the function is called.
function_body
Optional. Returns a value from the function to where it was called. A function without a return instruction automatically returns after all logically sequential instructions have been executed.
return
s a file that contains one or more functions and/or classes that may be reused to save time writing and debugging new source code.
module
Make the . (match any character), include
re.S
Allow case insensitive searches on string
re.I
Allows the expression to search for strings which span multiple lines
re.M
looks through the entire string for the pattern specified.
search()
which isolates just that segment of the string.
group()
returns a list of matches to all non-overlapping values in a specified string. This is useful when there may be more than one instance of data to extract.
findall()
occurs when a resource or event causes a major error within a program.
exception
A block of code defined as the body of a TRY statement executes. If an exception occurs in the program, the EXCEPT portion of the statement immediately executes,allowing the programmer to handle the error before the OS or Interpreter. This has the effect of ignoring any remaining code in the try block, and mitigating the crash proactively.
try-except
An illegal arithmetic operation, such as division by zero or a math result too large for the containing data type, has occurred
ArithmeticError
When an input or output operation fails; opening a file that does not exist or when network socket operations fail.
IOError
The subscripted index specified is out of range.
IndexError
An operation applied to an object of an inappropriate type.
TypeError
An operation or function received the correct data type, but the value given was inappropriate; trying to convert a string to a number. If the string contains anything other than numbers, this exception is raised.
ValueError
allows a program to send/receive data across a network. Similar to how a file handle provides access to a hard drive, a socket provides direct access to a network card.
socket
Creates socket object used for endpoint communication.
.socket()
Returns a string containing the local computer name.
.gethostname()
Attempts to bind the socket to a physical interface.
.bind()
Listen for incoming connections.
.listen()
Initiates connection from the client.
.connect()
Accepts an incoming connection, returns a tuple containing a connection object and source address/port of the client.
.accept()
Closes the socket.
.close()
Specifies optional hardware/socket configuration.
.setsockopt()
Reads string data from the socket, returns nothing if client closed the connection. N specifies number of bytes to read at one time, required.
.recv(N)
Sends string data to the client.
.send(s)
Closes the connection.
.close()
replies to a client with the same message it received and is typically used to allow the client and server to successfully communicate.
echo server