PyData Careers – Telegram
PyData Careers
20.9K subscribers
207 photos
4 videos
26 files
352 links
Python Data Science jobs, interview tips, and career insights for aspiring professionals.

Admin: @HusseinSheikho || @Hussein_Sheikho
Download Telegram
Interview question

What is __slots__?

Answer: By default, class instances store their attributes in the internal dictiondictct__. This is flexible, but it requires more memory and makes access to fields a bit slower, because the search is done in the dictionarslotsts__ allows you to fix a set of allowed attributes and abandon the usedictct__. Instead of a dictionary, Python allocates compact slots — thereby reducing the memory consumption for each object and speeding up access to attributes. This is especially important when millions of class instances are created in a program or the performance of data access is critical.

There is one restriction: it is not possible to add an attribute that is notslotsts__. To retain the ability to dynamically create fields, you can dictct__ to the list of slots.

tags:
#interview

@DataScienceQ
Please open Telegram to view this post
VIEW IN TELEGRAM
6👎1
❗️LISA HELPS EVERYONE EARN MONEY!$29,000 HE'S GIVING AWAY TODAY!

Everyone can join his channel and make money! He gives away from $200 to $5.000 every day in his channel

https://news.1rj.ru/str/+YDWOxSLvMfQ2MGNi

⚡️FREE ONLY FOR THE FIRST 500 SUBSCRIBERS! FURTHER ENTRY IS PAID! 👆👇

https://news.1rj.ru/str/+YDWOxSLvMfQ2MGNi
3
Question from the interview

What is a message broker and which ones are typically used with Python?

Answer: A message broker is an intermediary component that accepts messages from one service and delivers them to another, allowing microservices and asynchronous tasks to interact without direct connection. It ensures reliable delivery, queues, routing, and scalability.

In Python projects, RabbitMQ, Apache Kafka, and Redis are often used as simple broker solutions (for example, in combination with Celery). The choice depends on the tasks: Kafka for stream processing, RabbitMQ for flexible routing, and Redis for simple queues.


tags: #interview

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

What is an S3 storage and what is it used for?

Answer: S3 (Simple Storage Service) is a cloud-based object storage service designed for storing any type of files, from images and backups to static websites.

It is scalable, reliable, and provides access to files via URLs. Unlike traditional file systems, S3 does not have a folder hierarchy — everything is stored as objects in "buckets" (containers), and access can be controlled through policies and permissions.


tags: #interview

@DataScienceQ
Please open Telegram to view this post
VIEW IN TELEGRAM
6
Question from the interview

Why don't you need to store a session when using JWT?

Answer: JWT contains all the necessary information about the user directly in the token, including the expiration date and roles. The server simply verifies the token's signature and does not store any data between requests, so a separate session storage is not required.

tags: #interview

@DataScienceQ
Please open Telegram to view this post
VIEW IN TELEGRAM
3
What is NoneType?

NoneType — is a type to which the object None belongs, which is used to indicate an absent or undefined value. In Python, it is unique — there is only one instance of this type, that is, the None itself

@DataScienceQ 💚
Please open Telegram to view this post
VIEW IN TELEGRAM
3👍1
Question from the interview

I need to calculate 100 equations — is it worth using threads for this?

Answer:
If you need to calculate 100 equations in Python and it's a purely computational task without input-output, using threads is not advisable. In CPython, due to the GIL, calculations in threads are not performed in parallel, and switching threads only adds overhead.

For such tasks, it's better to use processes (multiprocessing, ProcessPoolExecutor) or move the calculations to native code (NumPy, C/C++ libraries). If the calculations are not large in size, parallelization may not pay off at all — then it's more reasonable to calculate sequentially.


tags: #interview

@DataScienceQ
Please open Telegram to view this post
VIEW IN TELEGRAM
3
This channels is for Programmers, Coders, Software Engineers.

0️⃣ Python
1️⃣ Data Science
2️⃣ Machine Learning
3️⃣ Data Visualization
4️⃣ Artificial Intelligence
5️⃣ Data Analysis
6️⃣ Statistics
7️⃣ Deep Learning
8️⃣ programming Languages

https://news.1rj.ru/str/addlist/8_rRW2scgfRhOTc0

https://news.1rj.ru/str/Codeprogrammer
Please open Telegram to view this post
VIEW IN TELEGRAM
2
Generated columns in PostgreSQL: speeding up filters without unnecessary calculations!

When the same expression is constantly calculated in WHERE, queries slow down. In PostgreSQL, this is solved with GENERATED ALWAYS AS … STORED — the expression is calculated once and stored as a regular field.

Create a table with a materialized expression:
CREATE TABLE events (
    id BIGSERIAL PRIMARY KEY,
    payload JSONB NOT NULL,
    event_type TEXT GENERATED ALWAYS AS (payload->>'type') STORED
);


Now event_type is no longer calculated on the fly — the value is directly in the row.

Filtering becomes easier and faster:
SELECT id
FROM events
WHERE event_type = 'purchase';


Add an index:
CREATE INDEX idx_events_event_type
    ON events(event_type);


Check:
EXPLAIN ANALYZE
SELECT id
FROM events
WHERE event_type = 'purchase';


🔥 There should be a Index Scan, without heavy operations on JSONB. Generated columns are great for repetitive calculations:

🚪 @DataScienceQ
Please open Telegram to view this post
VIEW IN TELEGRAM
5👏1
1. What data type is the variable rating = 4.9?
A. Integer
B. Float
C. String
D. Boolean
Correct answer: B.

2. What does the input() function always return?
A. Integer
B. Float
C. Boolean
D. String
Correct answer: D.

3. Which symbol is used to define a comment in Python?
A. //
B. /* */
C. #
D. --
Correct answer: C.

4. What does course[-1] return for a non-empty string?
A. First character
B. Last character
C. Second character
D. Entire string
Correct answer: B.

5. What is the result type of the / operator in Python?
A. Integer
B. Float
C. Boolean
D. String
Correct answer: B.

6. Which operator is used for exponentiation?
A. ^
B. *
C. **
D. //
Correct answer: C.

7. Which logical operator in Python negates a condition?
A. and
B. or
C. not
D. !=
Correct answer: C.

8. What does range(1, 5, 2) generate?
A. 1, 2, 3, 4
B. 1, 3
C. 2, 4
D. 0, 2, 4
Correct answer: B.

9. Which list method removes the last item?
A. remove()
B. delete()
C. pop()
D. clear()
Correct answer: C.

10. What is a tuple best described as?
A. A mutable list
B. A read-only list
C. A key/value store
D. A function container
Correct answer: B.

11. Which dictionary method safely returns a default value if a key is missing?
A. index()
B. find()
C. get()
D. pop()
Correct answer: C.

12. What is returned by a function that has no return statement?
A. 0
B. False
C. Empty string
D. None
Correct answer: D.

13. Which exception is raised when dividing by zero?
A. ValueError
B. TypeError
C. ZeroDivisionError
D. IndexError
Correct answer: C.

14. What is the purpose of the __init__ method in a class?
A. To delete objects
B. To initialize objects
C. To inherit methods
D. To define modules
Correct answer: B.

15. Which command installs a package from PyPI?
A. python install openpyxl
B. install pip openpyxl
C. pip add openpyxl
D. pip install openpyxl
Correct answer: D.
2👍2
PyData Careers
Photo
1. What will be the output of the following code?

def f(x, l=[]):
l.append(x)
return l

print(f(1))
print(f(2))


A. [1] then [2]
B. [1] then [1, 2]
C. Error due to mutable default
D. [] then []

Correct answer: B.

2. What is the result of this expression?

a = [1, 2, 3]
b = a
a += [4]


A. a = [1,2,3], b = [1,2,3]
B. a = [1,2,3,4], b = [1,2,3]
C. a = [1,2,3,4], b = [1,2,3,4]
D. Raises TypeError

Correct answer: C.

3. What does this code print?

print(bool([]), bool({}), bool(()))


A. True True True
B. False False False
C. False True False
D. True False True

Correct answer: B.

4. What is the output?

x = 10
def outer():
x = 20
def inner():
nonlocal x
x += 5
inner()
return x

print(outer())


A. 10
B. 20
C. 25
D. UnboundLocalError

Correct answer: C.

5. What happens when this code is executed?

class A:
def __init__(self):
self.x = 1

a = A()
a.__dict__['x'] = 2
print(a.x)


A. 1
B. 2
C. AttributeError
D. KeyError

Correct answer: B.

6. What is printed?

print([i for i in range(3)] is [i for i in range(3)])


A. True
B. False
C. SyntaxError
D. Depends on Python version

Correct answer: B.

7. What does this code output?

def gen():
yield from range(3)

print(list(gen()))


A. [0, 1, 2]
B. [1, 2, 3]
C. range(0, 3)
D. Error

Correct answer: A.

8. What is the result?

a = (1, 2, [3, 4])
a[2].append(5)
print(a)


A. Error: tuple is immutable
B. (1, 2, [3, 4])
C. (1, 2, [3, 4, 5])
D. (1, 2, 5)

Correct answer: C.

9. What does this print?

print({i: i*i for i in range(3)})


A. {0, 1, 4}
B. {0: 0, 1: 1, 2: 4}
C. [(0,0),(1,1),(2,4)]
D. Error

Correct answer: B.

10. What is the output?

print(type(lambda x: x))


A. <class 'function'>
B. <class 'lambda'>
C. <class 'callable'>
D. <class 'object'>

Correct answer: A.

11. What happens here?

try:
1 / 0
finally:
print("done")


A. Nothing is printed
B. ZeroDivisionError only
C. Prints "done" then raises ZeroDivisionError
D. Prints "done" only

Correct answer: C.

12. What is printed?

x = [1, 2, 3]
print(x[::-1] is x)


A. True
B. False
C. Error
D. Depends on interpreter

Correct answer: B.

13. What does this code demonstrate?

class A: pass
class B(A): pass
print(issubclass(B, A))


A. Duck typing
B. Multiple inheritance
C. Polymorphism
D. Inheritance

Correct answer: D.

14. What is the output?

print(all([0, 1, 2]), any([0, 1, 2]))


A. True True
B. False True
C. True False
D. False False

Correct answer: B.

15. What will this print?

x = 5
def f():
print(x)
x = 3

f()


A. 5
B. 3
C. UnboundLocalError
D. NameError

Correct answer: C.

16. What is the result?

a = {1, 2, 3}
b = {3, 2, 1}
print(a == b)


A. False
B. True
C. TypeError
D. Order dependent

Correct answer: B.

17. What does this output?

print(type((i for i in range(3))))


A. <class 'list'>
B. <class 'tuple'>
C. <class 'generator'>
D. <class 'iterator'>

Correct answer: C.

18. What is printed?

x = [1, 2, 3]
y = x.copy()
x.append(4)
print(y)


A. [1,2,3,4]
B. [4]
C. [1,2,3]
D. Error

Correct answer: C.

19. What does this evaluate to?

print(1 == True, 0 == False)


A. False False
B. True True
C. True False
D. False True

Correct answer: B.

20. What is the output?

def f():
try:
return 1
finally:
return 2

print(f())


A. 1
B. 2
C. None
D. RuntimeError

Correct answer: B.
6
Question from the interview

What are lambdas and what are their features?

Answer: Lambdas are anonymous functions without a name, which are used for short one-time operations. They consist of a single expression and automatically return its result. Most often, lambdas are passed to the map, filter, and reduce functions when a full function declaration is not required.

tags: #interview

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