Basic Python Interview Questions

    • Python basic interview questions * 1. Python lists and tuples What is the difference? * What are the main features 2. Python is? * 3. python programming language or a scripting language? * 4. Python is an interpreted language? * 5. What is pep 8? * 6. python is how memory management? * 7. What is the Python namespace? * What 8. python language PYTHONPATH that? * 9. What is a python module? To name a few commonly used built-in module in Python? * 10. Python in local and global variables * 11. python is case sensitive? * 12. Python type conversion * of which have built-in type 13. Python? * 14. python indentation in need? * 15. Python in the array and list what's the difference? * What is the function 16. Python? * What is the meaning of 17. init? * 18. What is a lambda function? * What the self is 19. Python? * 20. break, continue, pass usage? * 21. [:: - 1} is what role? * 22. How randomized items in the list in Python? * 23. What is the python iterator? * 24. How to generate random numbers in Python? * 25. range & xrange What is the difference? * 26. How do you write a comment in python? * 27. What is pickling and unpickling? * What is 28. python generators are? * 29. How do you put the first letter in a string of capital? * 30. How to convert string to lowercase? * 31. How to comment multiple lines in python? * What 32. Python in Docstrings that? * 33. The operator is, not in and what is the purpose? * 34. What usage in Python help () and dir () function is? * 35. Whenever Python quit, why not all the memory is deallocated? * What 36. Python in the dictionary (dictionary) that? * 37. How to use the ternary operator in python? * 38. * args, ** kwargs what is? Why do we use it? * What is the role 39. len () is? What is the role * 40. Python in "re" module split (), sub (), subn () These three methods are? * 41. What is the negative index, why use them? * 42. What is the Python package? * 43. How do you delete a file in Python? * 44. What is the python's built-in types such as: using a negative index of removing the last number of the list? * 45. NumPy array which provides advantages in (nested) Python list? * 46. How to add value to the python array? * 47. How do I delete python array of value? * 48. Python has OOps concept it? * 49. The deep and shallow copy copy What is the difference? * 50. How to implement multithreading in Python? * 51. python source code must be compiled to be? * 52. What is the Python library? A few examples. * 53. Python string split () method? * 54. How to import modules in python? * OOPS interview questions * 55. Explain inheritance Python. * 56. How to create a class in Python? * 57. What is a monkey patch? * 58. python support multiple inheritance? 59. Python * What is Polymorphism is? * 60. In Python how to define the package? * 61. How do you make data abstraction in Python? * 62. python whether to use the access specifiers? * 63. What Python pass in that? * 64. object () What is the role? * * 65. The basic coding Python written in Python program to perform the bubble sort algorithm. * 66. written in Python program to generate Star triangle. * 67. Write a program to generate Fibonacci series using Python. * 68. written in Python program to check whether a number is prime. * 69. written in Python program to check whether the sequence is a palindromic sequence. * 70. Write a single line, for the calculation of the number of files in capital letters. Even if the file is too big to fit into memory, your code should be able to work properly. 71. * written in Python numerical sorting algorithm dataset. * 72. Check the following code, write down the A0, A1, ... An of the final value. * Python libraries interview questions * 73. Flask explain what its benefits? * 74. Django than Flask, okay? The difference between the 75. Django, Pyramid and Flask *. * 76. discuss the Django framework. * 77. explain how to set up the database in Django. * 78. VIEW examples of how to write in Django? * 79. The reference to part of Django template. * 80. explain the use of sessions in Django framework? * 81. Django Model in the inheritance. * Web Scraping - Python interview questions * 82. How known locally saved image URL address? * 83. How to get Google cache limit any URLs or pages? * 84. delete data from before the IMDb 250 movies page. Only movie title, year and rating fields. * Data analysis - Python Interview Questions Python * 85. What is the map function? * 86. Why use NumPy? * How to get the maximum value of 87. The index in NumPy array in? * 88. How do you calculate percentiles using Python / NumPy? * 89. NumPy and SciPy What is the difference? * 90. How to use NumPy / SciPy create 3D graphics / visualization? 91. * Check whether a given number n is a power of 2 or * 0 to A converter 92. The calculation of the number of bits required to find B * 93. Repeat two distinct elements in the array element is found with the same set 94. * and a large number of bits in the next lower number 95. * given weight and the value of n items, these items into the maximum capacity of the total value W of the backpack backpack. * 96. Given a length of the rod and a series of n inches price, which contains all n dimensions smaller than the size of the price. Determining the maximum value and the sale of cut lever member obtainable. 97. The operator * two strings str1 and str2 and may be performed on a given str1. Find the minimum number of edit (operation) will be 'str1' is converted into 'str2' * 98. 0 and given a two-dimensional matrix to find the largest square that contains all 1. * 99. The length of the longest sequence found present in both. Sequence is the same sequence occurs in the relative order, but not necessarily contiguous. * 100. The longest sequence found for a given sequence length, so that all the elements of the sub-sequences are sorted in ascending order. * Given cost matrix 101. Cost [] [] and Cost [] [] is a position (m, n), * 102. One set into two subsets, so that the difference between the minimum subset to 103. * given a set of non-negative integer and a value, determines whether there is a subset of a given set, which sum equals the sum given. * 104. HackerRank problem using DP * 105. given distance dist, covering a total calculated distance with the embodiment 1, steps 3 and 106. * finds all possible words in the character plate 107. The breadth-first search traversal * * 108. * 109. the depth-first search traversal in the directed graph 110. the detected detection cycle * cycles undirected graph 111. * * Dijkstra's shortest path algorithm given edge 112. weighted to identify every pair of vertices in FIG. the shortest distance between the pattern 113. * 114 * realized. Kruskal minimum spanning tree algorithm of topological sorting * * 115. 116. Which of the following statements create a dictionary? (Multiple choice) * 117. Which is a partition? * The maximum possible length of 118. The identifier is how much? * 119. Why not encourage local variable names begin with an underscore? * 120. Which of the following is not a valid statement? * 121. The following is what Output? * 122. list1 assume that [2,33,222,14,25], what is list1 [-1]? * 123. To open the file c: scores.txt were writing, we use * Output 124. What is this code? * 125. try-except-else else part executed? 126. * two strings are anagram * * 127. Retrograde single chain preamble sequence 128. After the seek request sequence 129. * * 130. The two trees are the same tree seeking the maximum depth in the front 131. * postorder binary tree node 132. * * * 134. 133. traverse the level depth traversal issue * * 135. Keep the change fast row * 136. 137. 138. merge two ordered lists * farm chickens and rabbits, a total of 35 heads and 94 legs, calculate how many rabbits and chickens are just? * 139. Write a program that prints out [1,2,3] all the permutations * 140. Write a program that accepts a string from the console and print in reverse order. When try-except-else else part executed? 126. * two strings are anagram * * 127. Retrograde single chain preamble sequence 128. After the seek request sequence 129. * * 130. The two trees are the same tree seeking the maximum depth in the front 131. * postorder binary tree node 132. * * * 134. 133. traverse the level depth traversal issue * * 135. Keep the change fast row * 136. 137. 138. merge two ordered lists * farm chickens and rabbits, a total of 35 heads and 94 legs, calculate how many rabbits and chickens are just? * 139. Write a program that prints out [1,2,3] all the permutations * 140. Write a program that accepts a string from the console and print in reverse order. When try-except-else else part executed? 126. * two strings are anagram * * 127. Retrograde single chain preamble sequence 128. After the seek request sequence 129. * * 130. The two trees are the same tree seeking the maximum depth in the front 131. * postorder binary tree node 132. * * * 134. 133. traverse the level depth traversal issue * * 135. Keep the change fast row * 136. 137. 138. merge two ordered lists * farm chickens and rabbits, a total of 35 heads and 94 legs, calculate how many rabbits and chickens are just? * 139. Write a program that prints out [1,2,3] all the permutations * 140. Write a program that accepts a string from the console and print in reverse order.
      Basic Python Interview Questions
  1. Python lists and tuples What is the difference?
    The list is variable, i.e., they can be edited; is immutable tuples (a tuple list is not edited).

List slower than tuple; tuples faster than lists.

List syntax: list1 = [10, 'Chelsea', 20]; tuple Syntax: tup1 = (10, 'Chelsea', 20).

  1. What are the main features of the Python is?
    Python is an interpreted language. This means that, with the C language and its derivative different languages, Python does not need to be compiled before running. Other interpreted languages including PHP and Ruby.

Python is dynamically typed, when you declare a variable, you do not need to declare a variable of type. You can write directly analogous x = 111, or x = "I'm a string" this code, the program will not be given.

Python is very suitable object-oriented programming (OOP), because it allows the definition and combination of classes and inheritance. Python does not have access instructions (such as C ++, public, private).

In Python, functions are first-class objects. This means that they can be assigned to variable returns from other functions and passed to the function. The first class are class objects.

Write Python code fast, but speed is usually slower than compiled languages. However, Python allowed to join the extended C-based language, so we can optimize the code. numpy is a good example, it runs very fast, because a lot of arithmetic is not achieved through Python.

Python uses a very wide - Web applications, automation, scientific modeling, large data applications, and so on. It is also often referred to as a "glue language" so that other components of language and play very well.

  1. python programming language or a scripting language?
    Python is a scripting language, but in fact it can be compiled.

  2. Python is an interpreted language?
    Python is an interpreted language. The source code can be run directly, Python interpreter will convert the source code into an intermediate language, and then translated into machine code executed again.

  3. What is pep 8?
    PEP 8 is a programming specification. For every paragraph (Level) can be retracted, given specification pep 8 is 4 spaces.

  4. How python is memory management?
    Internal python use reference counting to keep track objects in memory, internal Python objects recorded the number of references, namely the reference count, when the object was created to create a reference count, when the object is no longer needed, this object the reference count is zero, it is garbage.

  5. What is the Python namespace?
    Namespace is a system that provides a unique name for each object in Python. Objects can be a variable or method. Python itself in the form of maintenance namespace Python dictionary.

  6. What python language PYTHONPATH that?
    Python PYTHONPATH search path is, by default we import the module from PYTHONPATH will find inside.

  7. What is a python module? To name a few commonly used built-in module in Python?
    Python module is a file containing Python code. This code may be a function or class variable. Python is .py module file containing executable code.

Some commonly used built-in modules are:

getpass
os
sys
subprocess
hashlib
json
pickle
shutil
time
datetime
re
random
configparser
traceback
yaml
itertools
logging

  1. Local and global variables in Python
    variables defined in the subroutine called local variables, the variable a defined at the beginning in a program called global variables.

Global variable scope is the entire program, the local variable scope is defined subroutines of the variable.

Example:

a=2 #Global Variable
def add():
b=3 #Local Variable
c=a+b
print(c)
add()
Output: 5

  1. whether python is case-sensitive?
    Yes. Python is a case-sensitive language.

  2. The Python type conversion
    type conversion means to convert one data type to another data type.

int () - converts any data type is an integer type

float () - converts any data type to float

ord () - characters converted to an integer

hex () - converts integers to hexadecimal

oct () - integer octal

tuple () - This function is used to convert a tuple.

set () - This function returns after conversion type set.

list () - This function is used to any type of data into a list.

dict () - This function is used to order tuples (key, value) is converted to the dictionary.

str () - used to convert the integer to a string.

complex () - is used to create a plurality of real + imag * j or transformed string or a plural number. If the first parameter is a string, there is no need to specify the second parameter.

  1. What have built-in types in Python?
    Python built-in data types immutable

Numeric
string
tuple
Python type variable built-in data

List
dictionary
set

  1. whether to indent in python?
    Python indent. Python syntax allows arbitrary code blocks indented a few spaces, but all located in the same block of code statements must be kept the same indentation, not what indented three spaces at indented four spaces.

  2. Python in the array and list what's the difference?
    list is a list of values can be found through the index, but not the entire list of numerical computation.

In [96]: b=[1,2]

The In [97]: B [. 1]
Out [97]: 2
the In [98]: type (B)
Out [98]: List
the In [99]: B + B
Out [99]: [. 1, 2,. 1, 2]
array is an array, the data can also look through the index value, but the value calculation can be performed for the entire array.

In [100]: a=np.array([1,2
In [101]: a[1]
Out[101]: 2
In [102]: type(a)
Out[102]: numpy.ndarray
In [103]: a+a
Out[103]: array([2, 4])

  1. What is the function in Python?
    Function is a block of code that's only done when it is called. In Python, the definition of a function to use def statement.

Example:

def nu():
pass

  1. init What is the meaning?
    It will be automatically executed when the class instance is created. Here is his own re-define the behavior of init.

Obj class:
DEF the init ():
Print 1
obj = Obj () # this time calling this method __init__
18. What is a lambda function?
lambda is a function may receive any of a plurality of parameters (optional parameters) and the function returns a single value of the expression.

Example:

list1 = [3,5,-4,-1,0,-2,-6]
sorted(list1, key=lambda x: abs(x))
[0, -1, -2, 3, -4, 5, -6]

  1. The self is what Python?
    It is an example of self or object class. In Python, this is clearly contained in the first parameter. However, the situation in Java is not the case, it is optional. It helps to distinguish the methods and attributes of the classes with local variables.

init method of self variable refers to the newly created object, whereas in other methods, it refers to the object whose method is called.

  1. break, continue, pass usage?
    break: When certain conditions are met and the control moves to the next loop terminates when the statement is allowed.
    continue: allows to skip certain portions of the cycle when certain conditions are met, and the control proceeds to the beginning of the cycle.
    pass: in case you need some code blocks in the grammar, but you want to skip its execution. This is basically a null operation. Nothing happens when performing this operation.
  2. [:: - 1} What is the role?
    [:: --1] array reversed sequence or sequences used.

E.g:

Array ARR AS Import
My_Array arr.array = ( 'I', [1,2,3,4,5])
My_Array [:: -. 1]
the Output: Array ( 'I', [5,4,3,2, 1])
[:: --1] reprint inverted copy of the ordered data structures, such as array or list. Original array or list remains unchanged.

  1. How randomized items in the list in Python?

Guess you like

Origin www.cnblogs.com/abdm-989/p/11415286.html