Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

2017 Hot Programming Language Python Big Event Review - with 10 classic interview questions


Jun 02, 2021 Article blog



Python's recent outbursts have been retweeted by the media, and even non-IT friends know Python exists.

 2017 Hot Programming Language Python Big Event Review - with 10 classic interview questions1

Python

Follow W3Cschool to review the big events at Python in 2017

January 2017 - Python Hot: See machine learning language trends from industry feedback

 2017 Hot Programming Language Python Big Event Review - with 10 classic interview questions2

Python is hot

February 2017 - Python officially moves to GitHub

 2017 Hot Programming Language Python Big Event Review - with 10 classic interview questions3  2017 Hot Programming Language Python Big Event Review - with 10 classic interview questions4

Python officially moved to GitHub

March 2017 - 7 of the best AI programming languages of 2017 - Python first!

 2017 Hot Programming Language Python Big Event Review - with 10 classic interview questions5  2017 Hot Programming Language Python Big Event Review - with 10 classic interview questions6

Python, the best AI programming language of 2017

July 2017 - Python is named the most popular programming language of 2017

 2017 Hot Programming Language Python Big Event Review - with 10 classic interview questions7  2017 Hot Programming Language Python Big Event Review - with 10 classic interview questions8

Python was named the most popular programming language of 2017

August 2017 - Python surpasses R as the most common language for data science and machine learning

 2017 Hot Programming Language Python Big Event Review - with 10 classic interview questions9  2017 Hot Programming Language Python Big Event Review - with 10 classic interview questions10

Python became the most common language for data science and machine learning

October 2017 - Ubuntu 17.10 no longer installs Python 2 by default

 2017 Hot Programming Language Python Big Event Review - with 10 classic interview questions11  2017 Hot Programming Language Python Big Event Review - with 10 classic interview questions12

Ubuntu 17.10 no longer installs Python 2 by default

November 2017 - Numpy announces that it no longer supports python2.7

 2017 Hot Programming Language Python Big Event Review - with 10 classic interview questions13  2017 Hot Programming Language Python Big Event Review - with 10 classic interview questions14

Numpy announced that it no longer supports python2.7

December 2017 - Python enters Shandong Primary School textbooks and is included in the National Computer Level Examination

 2017 Hot Programming Language Python Big Event Review - with 10 classic interview questions15  2017 Hot Programming Language Python Big Event Review - with 10 classic interview questions16

Python enters Shandong Primary School textbooks

Isn't that a shock? I n addition to the above, there are a lot of news, such as "Microsoft is considering adding Python as the official Excel scripting language", we do not list. Below we still talk about together to see W3Cschool for everyone to organize 10 classic Python interview questions, after all, such a hot language in the next interview how much will be involved in it

10 Python classic interview questions

  1. How do random numbers are generated in Python?
    A: Random module

    Random integer: random.randint (a,b): Returns random integer x, a< x<.b

    random.randrange (start, stop,,step)): returns a random integer between (start, stop, step), excluding the end value.

    Random real number: random.random ( ): Returns floating points between 0 and 1

    random.uniform (a,b): Returns floats within the specified range.

  2. How does Python manage memory?
    A: From three aspects, one object reference counting mechanism, two garbage collection mechanism, three memory pool mechanism

    First, the reference counting mechanism of the object

    Python uses reference counts internally to keep track of objects in memory, all of which have reference counts.

    When the reference count increases:

    1, an object is assigned a new name

    2, put it in a container (such as a list, tuple, or dictionary)

    Where the reference count decreases:

    1, destroy the display of object aliases using the del statement

    2, the reference is out of scope or re-assigned

    The sys.getrefcount () function gets the object's current reference count

    In most cases, the reference count is much larger than you might guess. For immutable data, such as numbers and strings, the interpreter shares memory at different parts of the program to save memory.

    Second, garbage collection

    1. When an object's reference count is zeroed, it is disposed of by the garbage collection mechanism.

    2. When two objects, a and b, reference each other, the del statement reduces the reference count of a and b and destroys the name used to refer to the underlying object. H owever, because each object contains an app to other objects, the reference count is not zeroed and the object is not destroyed. ( Which results in a memory leak). To solve this problem, the interpreter periodically performs a loop detector to search for loops of inaccessible objects and delete them.

    Third, the memory pool mechanism

    Python provides a garbage collection mechanism for memory, but it puts unused memory in a memory pool instead of returning it to the operating system.

    1, Pymalloc mechanism. To speed up Python's execution efficiency, Python introduced a memory pool mechanism to manage applications and releases of small pieces of memory.

    2, all objects smaller than 256 bytes in Python use the allocator implemented by pymalloc, while large objects use the system's malloc.

    3, for Python objects, such as integers, floats, and List, there are separate private memory pools, and their memory pools are not shared between objects. That is, if you allocate and release a large number of integers, the memory used to cache those integers can no longer be allocated to floats.

  3. The difference between single quotes, double quotes, and three quotation marks
    A: Single and double quotes are equivalent, if you want to wrap, you need a symbol (), three quotation marks can wrap directly, and you can include comments

    If you want to represent the let's go string

    Single quote: s4 s 'Let's go'

    Double Quotes: s5 - "Let's go"

    s6 = ‘I realy like“python”!’

    That's why both single and double quotes represent strings

  4. What is a lambda function? What's the benefit of it?
    A: Lambda expressions are usually used when a function is needed, but you don't want to bother naming a function, which means an anonymous function

    lambda function: The primary use is to point short callback functions

    lambda [arguments]:expression

    >>> a=lambdax,y:x+y

    >>> a(3,11)

  5. What's the difference between match() and search() in Python?

    A: In the re module, match (pattern, string, flags)) checks to see if the beginning of the string matches pattern.

    In the re module, the first matching value of the findern is searched for in the string.

    >>>print(re.match(‘super’, ‘superstition’).span())

    (0, 5)

    >>>print(re.match(‘super’, ‘insuperable’))

    None

    >>>print(re.search(‘super’, ‘superstition’).span())

    (0, 5)

    >>>print(re.search(‘super’, ‘insuperable’).span())

    (2, 7)

  6. How do I convert tuple and list in Python?
    A: Just use the tuple and list functions directly, type() to determine the type of object

  7. How do I set a global variable in a fusion?
    A: The workaround is to insert a global declaration at the beginning of the fusion:

    def f()

    global x

  8. How do I query and replace a text string with Python?
    A: You can query and replace it using the sub() function or subn(function in the re module.

    Format: sub (replace, string, count-0) (replacement is the text that is replaced, string is the text that needs to be replaced, count is an optional parameter, referring to the maximum number of replacements)

    >>> import re

    >>>p=re.compile(‘blue|white|red’)

    >>>print(p.sub(‘colour’,'blue socks and red shoes’))

    colour socks and colourshoes

    >>>print(p.sub(‘colour’,'blue socks and red shoes’,count=1))

    colour socks and redshoes

    The subn() method performs the same effect as sub(), but it returns a two-dimensional array that includes the new string after the replacement and the total number of replacements

  9. When matching HTML tags with Python, <. d <. What's the difference between >?
    A: The term is Greedy Match (< >) and non-greedy matches (< ?> )

    For example:

    test

    <. > :

    test

    <.?> :

  10. How does Python copy an object? (Assignment, shallow copy, deep copy difference)
    A: Assignment is a new reference to the object that is created, and modifying any one of the variables affects the other.

    Shallow copy: Create a new object, but it contains a reference to the item contained in the original object (if one object is modified by reference, the other will also be modified)

    Deep copy: Create a new object, and recursively copy the object it contains (modify one of them, the other does not change) (copy module's deep.deepcopy() function)

The above is the W3Cschool small compilation of Python 2017 big event review and 10 classic Python interview questions, I hope to help you.

WeChat public number search "w3c technical tutorial" or download w3cschool app, follow the latest programming information and programmer dynamics!

 2017 Hot Programming Language Python Big Event Review - with 10 classic interview questions17