interview preparation

1. Interview question preparation 
a. Talk about your differences between Python and other languages?
  Use: Python's class library is complete and concise. If you want to achieve the same function, a few lines of code in Python can be solved, others may require many lines.
  Speed: The running speed of Python is slower than that of other languages.
  1. 1. Simple

    Python is a language that represents simple ideas.

    2. Easy to learn

    Python has an extremely simple syntax.

    3. Free and open source

    Python is one of FLOSS (Free/Open Source Software).

    4. High-level languages

    Programs written in Python do not need to worry about low-level details such as how to manage the memory used by the program.

    5. Portability

    Python has been ported to many platforms including Linux, Windows, FreeBSD, Macintosh, Solaris, OS/2, Amiga, AROS, AS/400, BeOS, OS/390, z/OS, Palm OS, QNX, VMS, Psion, Acom RISC OS, VxWorks, PlayStation, Sharp Zaurus, Windows CE and even PocketPC.

    6. Interpretation

    Can be run directly from source. Inside the computer, the python interpreter converts the source code into an intermediate form of bytecode, which is then translated into the machine language used by the computer.

    7. Object Oriented

    Python supports both procedural and object-oriented programming.

    8. Scalability

    Some programs can be written in other languages, such as c/c++.

    9. Embeddable

    Python can be embedded into c/c++ programs to provide scripting capabilities.

    10. Rich Libraries

    The Python standard library is indeed huge. It helps you with all kinds of jobs including regular expressions, documentation generation, unit testing, threading, databases, web browsers, CGI, FTP, email, XML, XML-RPC, HTML, WAV files, cryptography, GUIs (Graphical User Interface), Tk and other system related operations.

shortcoming:

running slow


b. Why learn python?
Simple and easy to learn: Compared with other programming languages, Python is a relatively easy programming language to learn.

Beautiful syntax: The Python language strives for concise and beautiful code.

Rich and powerful library: The class library of the Python language is very comprehensive, including class libraries that solve various problems.

High development efficiency: Because the Python language has a rich and powerful class library, the development efficiency of Python can be significantly improved.

Wide range of application areas: for example, web development, network programming, automated operation and maintenance, Linux system management, data analysis, scientific computing, artificial intelligence, machine learning, etc.
c. Data type:
- string
    join
    split
    strip
    index
    find
    len
    str[]
    count
- dictionary
    .get
    .pop
     .fromkeys():
     .has_key():
     .items():
     .keys():
     .setdefault( ):
     .update():
     .values():

- tuple

      1. Join - '+' joins 2 tuples to form a new tuple

      2. Repeat - '*' repeats a tuple at the end

      3. Delete - a tuple cannot delete its elements, but a tuple can be deleted in its entirety, del tup

      4. Tuple indexing and interception - similar to strings tup[index]/tup[1:3]

      5.len(tup) - returns the length of the tuple

      6.max(tup) - returns the maximum value of the tuple

      7.min(tup) - returns the minimum value of the tuple

      8. tuple(seq) - convert a list to a tuple

 

      9.tuple.index(obj): Find the index value of the first match of a value from a tuple

      10.tuple.count(obj): Count the number of times an element appears in a tuple


- list
    

      1.list.append(obj) - add a new element at the end of the list, return value: none.

      2.list.count(obj) - Count the number of times an element (value in the list) appears in the list, return value: return the number of times.

      3.list.extend(seq) - add multiple values ​​at the end of the list at one time (similar to append directly changing the list), seq must be a list or range(), return value: none.

      4.list.index(obj) - Find the index of the first matching parameter obj (value), return value: return the index value.

      5.list.insert(index,obj) - insert the value (obj) into the specified index (index), return value: none.

      6.list.pop(obj=list[-1]) - delete the element in the list (the last item is deleted by default), return value: return the value of the deleted item.

      7.list.remove(obj)——Remove the first match whose value is obj, return value: None.

      8.list.reverse() - List reverse order, no parameters, no return value.

      9.list.sort([func]) - sort the list, according to letters and numbers from small to large, the data type of the list should be the same (the same number or the same string), func is the specified method (optional parameter)

      10.list.clear() - clears the list, similar to del a[:], return value: none.

      11.list.copy() - copy the list and return, return value: the copied list.


- collections
    add, remove, update, pop, union() union, issubset() returns True if another collection contains this collection, intersection() intersection, difference() difference
- collections
    namedtuple uses attributes to refer to certain parts of the dictionary elements, deque two-way list, defaultdict key does not exist, take default, OrderedDict ordered key dictionary, Counter counter

d. Function
- what is passed as a function parameter?
      The passing of function parameters in Python is the address of the object pointed to by the variable
      1. Immutable objects are used as function parameters, which are equivalent to passing by value. 
      2. Mutable objects are used as function parameters, which are equivalent to passing by reference
  
- def func(a,b=[]):pass
  

      - lambda expression 
      A concise representation of simple functions--an anonymous function, the body is an expression, and returns the function object itself,
- List comprehension []
      Using list comprehension, you can quickly generate a list, and you can deduce another list from one list, The code is very concise
- generator expression (for i in range(1))
      The generator expression returns not a list type object, but a generator object, saving space
- Question:
val = [lambda :i+ 1 for i in range(10)]
val[0] ##<function <listcomp>.<lambda> at 0x00000290D02C1E18>
data = val[0]()
print(data) ##10
      - Common built-in functions: 
- map
        traverses the sequence, operates on each element in the sequence, and finally obtains a new sequence.
- reduce
        accumulates all elements in the sequence
- filter filters
        the elements in the sequence, and finally obtains a sequence that meets the conditions
- zip
        zip accepts a series of iterable objects as parameters, and packs the corresponding elements in the object into tuples , then returns an object of type zip

 


- instance
        isinstance() function to determine whether an object is of a known type, similar to type()
- type
        type() function returns the type of the object if you only have the first parameter, and returns the new type object with three parameters

- 
- Generators, iterators, decorators
      A function containing the yield keyword is a generator
      An iterable object containing iter and next methods is called an  
      iterator   Adding functions before and after a function does not affect the syntactic sugar of the function itself
      
2. Review-
wtforms
- SQLALchemy

question:
a. What does wtforms do?
      --Form validation, rendering labels
b. What knowledge points are involved in wtforms? Where is it used?
- metaclass
        is used to specify which class to use to create the current class --wtforms sort fields
        metaclass--->class--->instance 
-encapsulation:
        wtforms--UnboundField
        restframework--request
- __new__
        wtforms--instantiation process-field instantiation returns: not StringField, but UnboundField
        restframework--many=true 
        singleton mode--class
method- __mro__
        class inheritance order-
setattr
        cbv, django configuration file, wtforms instantiation: setattr(self, name, field)
         - type(...) 
        type creates class
c. ORM and native SQL comparison?
ORM is simple to operate, and the development efficiency is fast.
      The native SQL operation is complex, and the database execution efficiency is fast
. d. What ORM frameworks have you used?  
      djangoORM
      SQLAlchemy



e. SQLAlchemy 
- database connection pool
- native SQL
- ORM
- table operation
- default value
- index (joint index, if you want to hit the "leftmost prefix" rule)
- set table in sqlalchemy:
- engine
- encoding
- record operation
- CRUD

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325235877&siteId=291194637