PyData Careers
20.7K subscribers
196 photos
4 videos
26 files
341 links
Python Data Science jobs, interview tips, and career insights for aspiring professionals.
Download Telegram
Interview question

What is the purpose of a pooling layer in a Convolutional Neural Network (CNN)?

Answer: A pooling layer (like Max Pooling or Average Pooling) is used to progressively reduce the spatial size (width and height) of the feature maps. This serves two main purposes: 1) It reduces the number of parameters and computational complexity, which helps to control overfitting. 2) It introduces a degree of translation invariance, meaning the network becomes more robust to small shifts and distortions in the position of features in the input image.

tags: #interview #cnn #deeplearning

━━━━━━━━━━━━━━━
By: @DataScienceQ
Interview question

What is the difference between the == (loose comparison) and === (strict comparison) operators in PHP?

Answer: The == operator is for loose comparison, checking for value equality after type juggling. For example, 1 == "1" is true. The === operator is for strict comparison, checking for both value AND type equality, without any type conversion. So, 1 === "1" is false. It's generally safer to use === to avoid unexpected bugs.

tags: #interview #php

━━━━━━━━━━━━━━━
By: @DataScienceQ
Interview question

What is the difference between isset() and empty() in PHP?

Answer: isset() returns true only if a variable is declared and is not NULL. In contrast, empty() returns true if a variable is considered "falsy", which includes NULL, false, 0, "0", an empty string "", or an empty array. A key difference is that a variable like $var = 0; is set (so isset() is true), but also considered empty (so empty() is true).

tags: #interview #php

━━━━━━━━━━━━━━━
By: @DataScienceQ
1
Interview question

Why is it better to use os.path.join() to construct paths instead of simple string concatenation?

Answer: Because os.path.join() handles cross-platform compatibility automatically. Operating systems use different path separators (e.g., / for Linux/macOS and \ for Windows). Hardcoding a separator like 'folder' + '/' + 'file' will break on a different OS. os.path.join('folder', 'file') correctly produces folder/file or folder\file depending on the system, making the code robust and portable.

tags: #interview #python #os

━━━━━━━━━━━━━━━
By: @DataScienceQ
1
Interview Question

How to get the current module's name?

Answer: The module name is available through the built-in variable name. If the module is imported, name contains its full name in the namespace. If the module is run as the main script, name automatically takes the value "main".

tags:
#interview

@DataScienceQ
Please open Telegram to view this post
VIEW IN TELEGRAM
1
Interview question

When would you use the __slots__ attribute in a Python class, and what is its main trade-off?

Answer: The __slots__ attribute is used for memory optimization. By defining it in a class, you prevent the creation of a __dict__ for each instance, instead allocating a fixed amount of space for the specified attributes. This is highly effective when creating a large number of objects. The primary trade-off is that you lose the ability to add new attributes to instances at runtime.

tags: #python #interview

━━━━━━━━━━━━━━━
By: @DataScienceQ
Interview question

What is None in Python?

Answer: None is a special value that represents the absence of a value or emptiness. It is used to indicate that a variable or function does not have a meaningful value. None is an object and the only value of the NoneType type. In Python, None is also used as the default value for function arguments if the argument was not explicitly provided.

tags: #interview

@DataScienceQ
Please open Telegram to view this post
VIEW IN TELEGRAM
Interview question

What is GIL in Python, why is it needed, and how can it be bypassed?

Answer: GIL (Global Interpreter Lock) is a mechanism in the CPython interpreter that ensures only one thread can execute Python bytecode at a time. It was introduced to simplify memory management and ensure thread safety of built-in data structures.

However, due to the GIL, multithreading in Python does not provide true CPU-level parallelism: even if multiple threads are created, they will run sequentially rather than simultaneously, which limits performance in computationally intensive tasks.

This limitation can be bypassed by using modules like multiprocessing, which run separate processes with their own memory and their own GIL. Heavy logic can also be moved to native C extensions or interpreters without a GIL, such as Jython or experimental versions of PyPy.


tags: #interview

@DataScienceQ
Please open Telegram to view this post
VIEW IN TELEGRAM
Interview question

What is the difference between asynchrony, multithreading, and multiprocessing?

Answer: Asynchrony works within a single thread and does not block program execution — while some operations wait for I/O completion, others continue running.

Multithreading uses multiple threads within one process that share memory and can run in parallel with coordination among them.

Multiprocessing launches several isolated processes, each with its own address space and resources, allowing true parallelism at the CPU level.

Simply put, asynchrony is efficient for I/O tasks, threads are used for tasks with shared data, and processes are for resource-intensive computations where load distribution across cores is important.


tags: #interview

@DataScienceQ
Please open Telegram to view this post
VIEW IN TELEGRAM
1
Interview Question

How to view an object's methods?

Answer: To see all methods and attributes associated with a specific object, you can use the dir() function. It takes the object as an argument and returns a list of all attribute and method names of the object.

tags: #interview

@DataScienceQ
Please open Telegram to view this post
VIEW IN TELEGRAM
2🔥1
Interview Question

What is the GIL (Global Interpreter Lock) in Python, and how does it impact the execution of multi-threaded programs?

Answer: The Global Interpreter Lock (GIL) is a mutex (or a lock) that allows only one thread to hold the control of the Python interpreter at any one time. This means that in a CPython process, only one thread can be executing Python bytecode at any given moment, even on a multi-core processor.

This has a significant impact on performance:

For CPU-bound tasks: Multi-threaded Python programs see no performance gain from multiple CPU cores. If you have a task that performs heavy calculations (e.g., image processing, complex math), creating multiple threads will not make it run faster. The threads will execute sequentially, not in parallel, because they have to take turns acquiring the GIL.

For I/O-bound tasks: The GIL is less of a problem. When a thread is waiting for Input/Output (I/O) operations (like waiting for a network response, reading from a file, or querying a database), it releases the GIL. This allows another thread to run. Therefore, the threading module is still highly effective for tasks that spend most of their time waiting, as it allows for concurrency.

How to achieve true parallelism?

To bypass the GIL and leverage multiple CPU cores for CPU-bound tasks, you must use the multiprocessing module. It creates separate processes, each with its own Python interpreter and memory space, so the GIL of one process does not affect the others.

tags: #Python #Interview #CodingInterview #GIL #Concurrency #Threading #Multiprocessing #SoftwareEngineering

━━━━━━━━━━━━━━━
By: @DataScienceQ
1
Interview question

What objects can be put into a set?

Answer: In Python, a set can only contain hashable (i.e., immutable) objects. This means you can put numbers, strings, tuples (if all their elements are also hashable), boolean values, and other immutable types into a set.

Objects like list, dict, set, and other mutable structures cannot be put in: they do not have a hash function (hash) and will cause a TypeError.

ta
gs: #interview

@DataScienceQ
Please open Telegram to view this post
VIEW IN TELEGRAM
1
Interview Question

What can be a key in a dictionary?

Answer: Dictionaries in Python are hash tables. Instead of keys, hashes are used in the dictionary. Accordingly, any hashable data type can be a key in the dictionary, which means all immutable data types.

tags: #interview

➡️ @DataScienceQ
Please open Telegram to view this post
VIEW IN TELEGRAM
3
Interview Question

What is a deep copy?

Answer: A deep copy is a complete duplication of an object along with all nested structures. Changes to the original do not affect the copy, and vice versa.

In Python, this is done using copy.deepcopy(), which creates a fully independent data structure, including nested lists, dictionaries, and other objects.


tags: #interview

@DataScienceQ
Please open Telegram to view this post
VIEW IN TELEGRAM
👍41
Interview Question

Why does list.sort() return None instead of the sorted list?

Answer: The list.sort() method modifies the list in place and intentionally returns None to clearly indicate that the sorting was done but no new list was created. This prevents confusion between modifying the object and creating its copy.

If a new sorted list is needed, the built-in sorted() function is used, which returns the result without changing the original.


tags: #interview

@DataScienceQ
Please open Telegram to view this post
VIEW IN TELEGRAM
Interview Question

Are there generics in Python like in Java or C++?

Answer: Yes, but only at the annotation level. Since Python 3.5, generic types (List[T], Dict[K, V]) have appeared through the typing module, but they are intended for static checking and do not affect the program's behavior at runtime.

tags: #interview

@DataScienceQ
Please open Telegram to view this post
VIEW IN TELEGRAM
Interview Question

What do you know about NoSQL databases?

Answer: NoSQL databases do not use a rigid tabular model and work with more flexible data structures. They do not require a fixed schema, so different records can have different sets of fields.

These databases scale well horizontally: data is distributed across cluster nodes, which helps handle high loads and large volumes. Different storage models are supported — key-value, document, columnar, and graph. This allows choosing the appropriate structure for a specific task.

Common systems include MongoDB (documents), Cassandra (columns), Redis (key-value), and Neo4j (graphs). They are used where scalability, speed, and data flexibility are important.


tags: #interview

https://t.iss.one/DataScienceQ
Please open Telegram to view this post
VIEW IN TELEGRAM
Interview Question

What does it mean that a QuerySet in Django is "lazy"?

Answer: "Lazy" QuerySet means that Django does not make a database query at the moment of creating the QuerySet. When you call .filter(), .exclude(), .all(), etc., the query itself is not executed yet — only an object describing the future SQL is created.

The actual database access happens only when the results are really needed: when iterating over the QuerySet, calling list(), count(), first(), exists(), and other methods that require data.

This approach helps avoid unnecessary database hits and improves performance — queries are executed only at the moment of real necessity.


tags: #interview

https://t.iss.one/DataScienceQ
Please open Telegram to view this post
VIEW IN TELEGRAM
👍1
Interview question

What is the difference between calling start() and run() on threading.Thread?

Answer: The start() method creates a new thread and automatically calls run() inside it.

If you call run() directly, it will execute in the current thread like a normal function — without creating a new thread and without parallelism.

This is the key difference: start() launches a separate execution thread, while run() just runs the code in the same thread.


tags: #interview

https://t.iss.one/DataScienceQ
Please open Telegram to view this post
VIEW IN TELEGRAM
👍1
Interview Question

What does nonlocal do and where can it be used?

Answer: nonlocal allows you to modify a variable from the nearest enclosing function without creating a new local one. It only works inside a nested function when you need to change a variable declared in the outer, but not global, scope.

This is often used in closures to maintain and update state between calls to the nested function.


tags: #interview

@DataScienceQ
Please open Telegram to view this post
VIEW IN TELEGRAM
2