šāļøTODAY FREEāļøš
Entry to our VIP channel is completely free today. Tomorrow it will cost $500! š„
JOIN š
https://t.me/+MPpZ4FO2PHQ4OTZi
https://t.me/+MPpZ4FO2PHQ4OTZi
https://t.me/+MPpZ4FO2PHQ4OTZi
Entry to our VIP channel is completely free today. Tomorrow it will cost $500! š„
JOIN š
https://t.me/+MPpZ4FO2PHQ4OTZi
https://t.me/+MPpZ4FO2PHQ4OTZi
https://t.me/+MPpZ4FO2PHQ4OTZi
ā¤2
Checking Memory Usage in Python
psutil is imported, then through psutil.virtual_memory() memory data is obtained.
The function convert_bytes converts bytes to gigabytes.
Then the code calculates:
- total RAM
- available RAM
- used RAM
- percentage usage
And outputs this to the console.
Or simply press CTRL + ALT + DELETE and open Task Manager. It has worked since the days of Windows 95.
The RAM usage percentage loses its meaning if you have Chrome open ā it will consume everything on its own š
š https://t.me/DataScienceQ
psutil is imported, then through psutil.virtual_memory() memory data is obtained.
The function convert_bytes converts bytes to gigabytes.
Then the code calculates:
- total RAM
- available RAM
- used RAM
- percentage usage
And outputs this to the console.
import psutil
memory = psutil.virtual_memory()
def convert_bytes(size):
# Convert bytes to GB
gb = size / (1024 ** 3)
return gb
total_gb = convert_bytes(memory.total)
available_gb = convert_bytes(memory.available)
used_gb = convert_bytes(memory.used)
print(f"Total RAM: {total_gb:.3f} GB")
print(f"Available RAM: {available_gb:.3f} GB")
print(f"Used RAM: {used_gb:.3f} GB")
print(f"RAM Usage: {memory.percent}%")
The RAM usage percentage loses its meaning if you have Chrome open ā it will consume everything on its own
Please open Telegram to view this post
VIEW IN TELEGRAM
ā¤3
What can be a key in a dictionary?
Answer:
tags: #interview
Please open Telegram to view this post
VIEW IN TELEGRAM
ā¤4š3
Why does
isinstance(True, int) return True?Answer:
tags: #interview
Please open Telegram to view this post
VIEW IN TELEGRAM
ā¤7š1š„1
Forwarded from Machine Learning with Python
Our Group on Signal (only for Programmers)
https://signal.group/#CjQKIPcpEqLQow53AG7RHjeVk-4sc1TFxyym3r0gQQzV-OPpEhCPw_-kRmJ8LlC13l0WiEfp
https://signal.group/#CjQKIPcpEqLQow53AG7RHjeVk-4sc1TFxyym3r0gQQzV-OPpEhCPw_-kRmJ8LlC13l0WiEfp
ā¤1
Please open Telegram to view this post
VIEW IN TELEGRAM
ā¤7
What is Big O notation?
Answer:
For example, O(n) grows linearly, O(n²) - quadratically, O(1) - does not depend on the size of the input.
Big O does not give exact figures, but allows you to compare algorithms in terms of their scalability.
tags: #interview
Please open Telegram to view this post
VIEW IN TELEGRAM
ā¤8
What is
__slots__?Answer:
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:
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://t.me/+YDWOxSLvMfQ2MGNi
ā”ļøFREE ONLY FOR THE FIRST 500 SUBSCRIBERS! FURTHER ENTRY IS PAID! šš
https://t.me/+YDWOxSLvMfQ2MGNi
Everyone can join his channel and make money! He gives away from $200 to $5.000 every day in his channel
https://t.me/+YDWOxSLvMfQ2MGNi
ā”ļøFREE ONLY FOR THE FIRST 500 SUBSCRIBERS! FURTHER ENTRY IS PAID! šš
https://t.me/+YDWOxSLvMfQ2MGNi
ā¤3
What is a message broker and which ones are typically used with Python?
Answer:
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
Please open Telegram to view this post
VIEW IN TELEGRAM
ā¤5
What is an S3 storage and what is it used for?
Answer:
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
Please open Telegram to view this post
VIEW IN TELEGRAM
ā¤6
Why don't you need to store a session when using JWT?
Answer:
tags: #interview
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š
@DataScienceQ
Please open Telegram to view this post
VIEW IN TELEGRAM
ā¤3š1
I need to calculate 100 equations ā is it worth using threads for this?
Answer:
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
Please open Telegram to view this post
VIEW IN TELEGRAM
ā¤3
Forwarded from Machine Learning with Python
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://t.me/addlist/8_rRW2scgfRhOTc0
ā
https://t.me/Codeprogrammer
Please open Telegram to view this post
VIEW IN TELEGRAM
ā¤3
Generated columns in PostgreSQL: speeding up filters without unnecessary calculations!
When the same expression is constantly calculated in
Create a table with a materialized expression:
Now
Filtering becomes easier and faster:
Add an index:
Check:
š„ There should be a
šŖ @DataScienceQ
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';
Index Scan, without heavy operations on JSONB. Generated columns are great for repetitive calculations:Please open Telegram to view this post
VIEW IN TELEGRAM
ā¤5š1
1. What data type is the variable
A. Integer
B. Float
C. String
D. Boolean
Correct answer: B.
2. What does the
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
A. First character
B. Last character
C. Second character
D. Entire string
Correct answer: B.
5. What is the result type of the
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
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
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
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.
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.
ā¤3š2
PyData Careers
Photo
1. What will be the output of the following code?
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. 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?
A. True True True
B. False False False
C. False True False
D. True False True
Correct answer: B.
4. What is the output?
A. 10
B. 20
C. 25
D. UnboundLocalError
Correct answer: C.
5. What happens when this code is executed?
A. 1
B. 2
C. AttributeError
D. KeyError
Correct answer: B.
6. What is printed?
A. True
B. False
C. SyntaxError
D. Depends on Python version
Correct answer: B.
7. What does this code output?
A. [0, 1, 2]
B. [1, 2, 3]
C. range(0, 3)
D. Error
Correct answer: A.
8. What is the result?
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?
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?
A. <class 'function'>
B. <class 'lambda'>
C. <class 'callable'>
D. <class 'object'>
Correct answer: A.
11. What happens here?
A. Nothing is printed
B. ZeroDivisionError only
C. Prints "done" then raises ZeroDivisionError
D. Prints "done" only
Correct answer: C.
12. What is printed?
A. True
B. False
C. Error
D. Depends on interpreter
Correct answer: B.
13. What does this code demonstrate?
A. Duck typing
B. Multiple inheritance
C. Polymorphism
D. Inheritance
Correct answer: D.
14. What is the output?
A. True True
B. False True
C. True False
D. False False
Correct answer: B.
15. What will this print?
A. 5
B. 3
C. UnboundLocalError
D. NameError
Correct answer: C.
16. What is the result?
A. False
B. True
C. TypeError
D. Order dependent
Correct answer: B.
17. What does this output?
A. <class 'list'>
B. <class 'tuple'>
C. <class 'generator'>
D. <class 'iterator'>
Correct answer: C.
18. What is printed?
A. [1,2,3,4]
B. [4]
C. [1,2,3]
D. Error
Correct answer: C.
19. What does this evaluate to?
A. False False
B. True True
C. True False
D. False True
Correct answer: B.
20. What is the output?
A. 1
B. 2
C. None
D. RuntimeError
Correct answer: B.
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.
ā¤9
What are lambdas and what are their features?
Answer:
tags: #interview
Please open Telegram to view this post
VIEW IN TELEGRAM
ā¤5
What is serialization and why is it needed?
Answer:
A serialized object can then be deserialized ā its original structure can be restored in memory. This is necessary when transferring data between programs, caching, or interprocess communication.
tags: #interview
Please open Telegram to view this post
VIEW IN TELEGRAM
ā¤6