Вы находитесь на странице: 1из 1

PYTHON CLASSES AND MODULE

-------------------------
1) what is thw default namespace a program will run?-->the python namespace
2) the docstring is usefull for documentation but will also be returned with which
method?--> the help method
3) what special method must be used to create object with instances customized to a
specic ititial state?--> __init__
4) what is the downside to reading entire files before writing them,rather than
using one line at a time method of iteration of the readline method?--> memory
consumption can be exceed on very large file
5) which of the following are the best practices when following the guidline in PEP
8?-->for each layer of indentation 4 spaces should be used-->use meaningful names
when nameing python objects
6) what does using the if__name__=='__main__':syntax programming to do?-->execute
the that code block directly from the command line-->test the module to make sure
hat it is working properly
7) what is the decorator used to denote a class method,as opposed to an instance
method?..>@classmethod
8) in order to be able to write binary data to a file, you need to use either the
struct module pack. which other object can you see to encoe data, like text, into
binary data?-->the bytes object
9) which of the following does a class in python allow to represent?..> an object
10) which statment correctly creates a class using inheritance?-->class derived
class(Bseclass1,BaseClass2)
11) which are the techniques for reading a text file? --> using a read method-->
iterating over lines-->using the readlines method
12) when attempting to overwrite a setter from an inherited class,what must also be
declered in the subclass?--> the property
13) if something is decleared as a property,what then must be used to modify the
value?--> a setter function
14) what letter needs to be addded to the move when you are reading a binay file?--
>b
15) what benefites does overloading an operator provide to a programmer?--> have
the object appear in a particular way when printed or inspected by the
interpreter-->include additional automatic functionality to occure when operation
are done
16) what are possible solutions whn you have trobule importing a module you
created?--> add the path for the module to the sys.pah file-->change the working
directory to be the one that contains the module
17) which of the following are valid modes to st when writing to a file?-->a-->x
18) what are some charactericts of a properly defind function?---> it can be defind
to accept an unlimited amount of arguments-->the return keyword causes an exit
from the function with the value
19) what must you use to allow for command line arguments to be passed to a
function in a module or script?-->sys.argv
20) what are some charactericts of the relationship between class and types?--> a
class can be defind as a specific tpye-->an instance of a class will have the
string that was used todefind tghe class as its type

Вам также может понравиться