PyData Careers
20.7K subscribers
196 photos
4 videos
26 files
342 links
Python Data Science jobs, interview tips, and career insights for aspiring professionals.
Download Telegram
❔ 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
πŸ‘4❀1
Tip for clean tests in Python:

Structure your tests with the Arrange-Act-Assert pattern to improve readability and maintainability.

β€’ Arrange: Set up the test. Initialize objects, prepare data, and configure any mocks or stubs.
β€’ Act: Execute the code being tested. Call the specific function or method.
β€’ Assert: Check the outcome. Verify that the result of the action is what you expected.

import pytest
from dataclasses import dataclass, field


# Code to be tested
@dataclass
class Product:
name: str
price: float


@dataclass
class ShoppingCart:
items: list[Product] = field(default_factory=list)

def add_item(self, product: Product):
if product.price < 0:
raise ValueError("Product price cannot be negative.")
self.items.append(product)

def get_total_price(self) -> float:
return sum(item.price for item in self.items)


# Tests using the Arrange-Act-Assert pattern
def test_get_total_price_for_multiple_items():
# Arrange
product1 = Product(name="Mouse", price=25.50)
product2 = Product(name="Keyboard", price=75.50)
cart = ShoppingCart()
cart.add_item(product1)
cart.add_item(product2)

# Act
total_price = cart.get_total_price()

# Assert
assert total_price == 101.00


def test_get_total_price_for_empty_cart():
# Arrange
cart = ShoppingCart()

# Act
total_price = cart.get_total_price()

# Assert
assert total_price == 0.0


def test_add_item_with_negative_price_raises_value_error():
# Arrange
cart = ShoppingCart()
product_with_negative_price = Product(name="Invalid Item", price=-50.0)

# Act & Assert
with pytest.raises(ValueError, match="Product price cannot be negative."):
cart.add_item(product_with_negative_price)


#Python #Testing #CleanCode #SoftwareEngineering #Pytest #DeveloperTips #AAA

━━━━━━━━━━━━━━━
By: @DataScienceQ ✨
❔ 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
Hello! How can I assist you today?

By: @DataScienceQ πŸš€
❀2
❔ 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
300 Real Time SQL Interview.pdf
4.5 MB
300 Real Time SQL Interview practical Questions Asked at multiple companies
β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’

Anyone who's preparing for an interview just reading theoretical concept will not help definitely you need to have practical hands on in #sql so create table with some data and try this queries running by your self so can help you to understand the logic of similar kind of queries

If you're preparing for an interview this doc will help a lot in the perpetration If you're experienced also freshers can also get hands on by practicing these queries and get confidence.


https://t.iss.one/DataScienceQ
❀3
πŸš€ THE 7-DAY PROFIT CHALLENGE! πŸš€

Can you turn $100 into $5,000 in just 7 days?
Lisa can. And she’s challenging YOU to do the same. πŸ‘‡

https://t.iss.one/+AOPQVJRWlJc5ZGRi
https://t.iss.one/+AOPQVJRWlJc5ZGRi
https://t.iss.one/+AOPQVJRWlJc5ZGRi
❀2
❔ 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
πŸš€ THE 7-DAY PROFIT CHALLENGE! πŸš€

Can you turn $100 into $5,000 in just 7 days?
Lisa can. And she’s challenging YOU to do the same. πŸ‘‡

https://t.iss.one/+AOPQVJRWlJc5ZGRi
https://t.iss.one/+AOPQVJRWlJc5ZGRi
https://t.iss.one/+AOPQVJRWlJc5ZGRi
❔ 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
πŸ‘©β€πŸ’» Python Question / Quiz;

What is the output of the following Python code?
Please open Telegram to view this post
VIEW IN TELEGRAM
❀5
Channel name was changed to Β«PyData CareersΒ»
Channel photo updated
❔ 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
πŸ’Έ PacketSDK--A New Way To Make Revenue From Your Apps

Regardless of whether your app is on desktop, mobile, TV, or Unity platforms, no matter which app monetization tools you’re using, PacketSDK can bring you additional revenue!

● Working Principle: Convert your app's active users into profits πŸ‘₯β†’πŸ’΅

● Product Features: Ad-free monetization 🚫, no user interference

● Additional Revenue: Fully compatible with your existing ad SDKs

● CCPA & GDPR: Based on user consent, no collection of any personal data πŸ”’

● Easy Integration: Only a few simple steps, taking approximately 30 minutes

Join us:https://www.packetsdk.com/?utm-source=SyWayQNK

Contact us & Estimated income:
Telegram:@Packet_SDK
Whatsapp:https://wa.me/85256440384
Teams:https://teams.live.com/l/invite/FBA_1zP2ehmA6Jn4AI

⏰ Join early ,earn early!
❀2
🐍 Tricky Python Interview Question

> What will this code output and why?


def extend_list(val, lst=[]):
    lst.append(val)
    return lst

list1 = extend_list(10)
list2 = extend_list(123, [])
list3 = extend_list('a')

print(list1, list2, list3)


❓Question: Why are list1 and list3 the same?

πŸ” Explanation:

Default arguments in Python are evaluated once β€” at function definition, not at each call.

So lst=[] is created once and preserved between calls if you don't explicitly pass your own list.

🧠 What happens:

- extend_list(10) β†’ uses the shared list [], now it is [10]

- extend_list(123, []) β†’ creates a new list [123]

- extend_list('a') β†’ again uses the shared list β†’ [10, 'a']

πŸ‘‰ Result:

[10, 'a'] [123] [10, 'a']

βœ… How to fix:

If you want a new list created by default on each call, do this:


def extend_list(val, lst=None):
    if lst is None:
        lst = []
    lst.append(val)
    return lst


This is a classic Python interview trap β€” mutable default arguments.

It tests if you understand how default values and memory scope work.

https://t.iss.one/DataScienceQ ⭐️
Please open Telegram to view this post
VIEW IN TELEGRAM
❀1