Questions #1



Download 85,32 Kb.
bet2/24
Sana06.07.2022
Hajmi85,32 Kb.
#752107
1   2   3   4   5   6   7   8   9   ...   24
Bog'liq
interview en

Database:


54. What are the basic methods of working with a SQL database in Python?
55. What is an SQL transaction?
56. How to make a selection from a SQL database with a simple aggregation?
57. What does a query look like that performs a JOIN between tables and on itself?
58. How to send queries to SQL database without ORM?

Algorithms:


59. What are algorithms (eg Big-O notation)?
60. What are the basic sorting algorithms?
61. What is Bubble Sort and how does it work?
62. What is the linear complexity of sorting?

Questions #2. Python Interview Questions and Answers 2021


1) What is the difference between module and package in Python?
Each Python program file is a module that imports other modules as objects. Thus, a module is a way of structuring your program. The folder containing the Python program is called the module package.
2) What built-in types are available in Python?
This is one of the most common interview questions. Python has mutable and immutable built-in types.
Changeables include:

  • lists,

  • sets,

  • Dictionaries.

Representatives of immutable types are:

  • strings,

  • tuples,

  • Numbers.

3) What is a lambda function in Python?
The lambda is often used as an inline function and is a single anonymous function expression. It is used to create a new function object and return it at runtime.
lambda is an anonymous function in Python that can take an unlimited number of arguments and can have any number of parameters. However, a lambda function can only have one expression or statement. It is typically used in situations where an anonymous function is needed for a short period of time. Lambda functions can be used in one of two ways:
Lambda function example:

4) What does namespace mean?
A namespace is a naming system that is used to ensure that all objects in a program are named uniquely to avoid potential conflicts. In Python, these namespaces are implemented as dictionaries with name as key and object as value. As a result, different spaces can give their objects the same name.
Following are the three types of namespaces in Python:

  • Local Namespace - Includes local names within a function. The local namespace is temporarily created during a function call and is cleared when the function returns.

  • Global namespace - consists of the names of various imported packages/modules that are currently used in the project. The global namespace is created when the package is imported into the script, and is available until the script finishes executing.

  • Built-in namespace − It includes built-in Python functions and built-in names for different types of exceptions.

5) Explain the difference between list and tuple?
The list is mutable, but the tuple is not. Tuples can be hashed, as in the case of creating keys for dictionaries.
6) What is the difference between pickling and unpickling?
Any guide to Python interview questions and answers would not be complete without this question. In Python, the pickle module takes any Python object, converts it to a string representation, and dumps it into a file using the dump function. This process is known as pickling. The pickle.dump() function is used for this process .
On the other hand, the process of extracting the original Python object from the stored string representation is called unpickling. The pickle.load() function is used for this process .
7) What are decorators in Python?
The Python decorator is some update to the Python syntax to make it easier to change functions.
8) Difference between generators and iterators?
In Python, iterators are used to iterate over a group of elements (like in a list). Generators are a way to implement iterators. They use yield to return an expression from a function, but otherwise the generator behaves like a regular function.
9) How to convert number to string?
One of the most common interview questions. We can use the built-in str() function . For octal or hexadecimal representation of a number, we can use other built-in functions such as oct() or hex() .
10) How is the // operator used in Python?
Using the // operator between two numbers gives the quotient when dividing the numerator by the denominator. It is also called the no remainder division operator.

11) Does Python have a Switch or Case statement like in C?


No. However, we can create our own Switch function and use it.
12) What is the range() function and what are its parameters?
The range() function is used to create a list from numbers. Only integers are allowed, so arguments passed can be either negative or positive. The following options are allowed:

Where "stop" is the number of integers to generate, starting from 0. Example: list(range(5)) == [0,1,2,3,4]
Other parameters : range([start], stop[, step]) :

  • Start: sets the first number in the sequence.

  • Stop: Specifies the upper limit for the sequence.

  • Step: increment factor in the sequence.

13) How is %s used?
%s is a format specifier that converts any value to a string.
14) Is a Python function required to return a value?
Not
15) Does Python have a main() function ?
Yes there is. It is executed automatically whenever we run the script. If you want to change this natural order of things, use an if statement.
16) What is GIL?
GIL or Global Interpreter Lock is a mutex used to restrict access to Python objects. It synchronizes threads and prevents them from running at the same time.
17) What method was used before the "in" operator to check if a key exists in a dictionary?
has_key() method .

18) How to change the data type of the list?


To convert a list to a tuple, we use the tuple() function .
To turn it into a set, use the set() function .
To convert to a dictionary - dict() .
To turn into a string - join() .
19) What are the key features of Python?
This is one of the most common interview questions. Python is an open source, high-level, general-purpose programming language. Since it is a general purpose programming language and it comes with a large set of libraries, you can use Python to develop almost any type of application.
Some of its key features:

  • interpreted,

  • With dynamic typing,

  • Object Oriented,

  • English syntax.

20) Explain memory management in Python.
In Python, the memory manager takes care of memory management. It allocates it as space on the heap, which holds all Python objects and data structures. There are 4 built-in data structures in the language. This space is not directly accessible to the programmer. However, the underlying API allows the developer to access some coding tools.
In addition, Python has a built-in garbage collector that frees unused memory from heap space.
21) What is PYTHONPATH?
PYTHONPATH is an environment variable that is used to include extra directories when importing a module/package. Every time a module/package is imported, PYTHONPATH is used to check if the modules to be added exist in the existing directories. Normally the interpreter uses PYTHONPATH to determine which module to load.
22) Is Python case sensitive?
A programming language is considered case sensitive if it distinguishes between identifiers such as "myname" and "Myname". Simply put, it cares if the characters are lowercase or uppercase.
Let's look at an example:

Raising a NameError means that Python is case sensitive.
23) Explain the use of the help() and dir() functions .
In Python, the help() function is used to display documentation for modules, classes, functions, keywords, and so on. If help() takes no parameters, it launches an interactive help utility on the console.
The dir() function returns a valid list of attributes and methods on the object it is called on. Since the function is designed to get the most relevant data (instead of displaying full information), it behaves differently with different objects:

  • For modules/libraries, the dir() function returns a list of all the attributes contained in that module.

  • For class objects, dir() will return a list of all valid attributes and base attributes.

  • When no parameters are passed to it, the dir() function returns a list of attributes in the current scope.

24) What are Python modules?
Name some of the most commonly used built-in modules in Python?
Python modules are files containing Python code, which is either functional classes or variables. Modules are Python files with a .py extension. They may include a set of functions, classes, or variables that are defined and implemented. You can import and initialize a module using the import statement . You can learn more about modules in Python by reading the Python manual.
Here are some of the most commonly used built-in modules in Python:
Operating Systems

  • os,

  • sys,

  • math,

  • random,

  • datetime,

  • JSON.

25) Explain what "self" means in Python.
In Python, "self" is a keyword used to define an instance or object of a class. Unlike Java, where self is optional, Python takes it as the first parameter. Self helps to distinguish methods and attributes of a class from its local variables.
The variable self in the __init__ method refers to the created object or instance, while in other methods it refers to the object or instance whose method was called.
Questions #3

Strings



Download 85,32 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7   8   9   ...   24




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish