05 Flashcards

1
Q

The _________ function uses integers to indicate where to start, stop, and by how much it should change to create a sequence of integers.

A

range

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

If the numerical range is arithmetically invalid, it will raise an error T/F?

A

False, it will create an empty sequence

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Howe do you tell something is a function in python?

A

def

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do I edit or use a global variable inside a function

A

global x
x = 5

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

A ________ is a file that contains one or more functions and/or classes that may be reused to save time writing and debugging source code

A

python module

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you import a module in python?
How do you see a lit of available modules?

A

import re
help(‘module’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

When creating a expression/search pattern in python using regex whats the format of it?

A

expression = r”\w+”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

A ______ modifies the way a regulkar expression examines data. can you use the pipe to look at more then one?

A

flag, yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

_________ ___________ Makes the . (match any character)), include <newline></newline>

________ __________ Allow case insensitive searches on a string

________ __________ Allows the expression to search for strings which span multiple lines

A

re.DOTALL re.S

re.IGNORTECASE re.I

re.MULTILINE re.M

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

The ________ ___________ looks through the entire string for the pattern specified. If the pattern is found, a match object is returned, otherwise no value is returned

A

search function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

The _______ _________ returns a list of strings for each match to all non-overlapping values in a specified string

A

findall() function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

The __________ block is provided as a built-in technique to handle errors. What the syntax for it?

A

try-except

try:
sucessful code operation
except OsError
“There was a problem in meemory”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

_________________ An illegal arthi8metic operation. E.g. division by zero or a math result too large for the containing data type

_________ When a system function returns a system-related error. E.g. I/O failures like “file not found” or connection failures like “socket failures”

_______________ The subscripted index is specified out of range E.g., trying to access the 10th element of a list of five numbers

_____________ An operation applied to an object of an inappropriate data type. E.g. trying to divide a string by an integer

____________ An operation or function received the correct data type, but the value given was inappropriate

A

ArthimaticError

OsError

IndexError

TypeError

ValueError

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Sockets are __________ that allow software to communicate and send data across a network connection via access to a computers nic

A

objects

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

By default all sockets are tcp T/F?

A

T

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the steps in a socket session for the server then client?

A

server
socket()
bind()
Listen
accept()
send and recieve functions
close

client
socket()
bind() optional
connect()
send and recieve functions
close()

17
Q

______________ creates socket object used for endpoint communication

_____________ returns a string containig the local computer name

______________ Attempts to bind the socket to a physical interface

A

socket.socket()

socket.gethostname()

socket.bind()

18
Q

______________ listen for incoming connections

______________ initates connection from the client

______________ Accepts an incoming connection, returns a socket object to transmit data and the address of the requesting socket

A

socket.listen

socket.connect

socket.accept

19
Q

______________ closes the socket

_____________ specifies optional hardware/socket configuration

A

socket.close

socket.setsockopt()

20
Q

methods:

_____________ Reads data from the socket, returns nothing if client closed the connection the ___ parameter specifies number of bytes to read at one time, required.

____________ sends data across the established socket connection

A

socket.recv(N)

socket.sendall(s)