How does the
map() function work?Answer:
tags:#interview
Please open Telegram to view this post
VIEW IN TELEGRAM
❤5
🚀 Pass Your IT Exam in 2025——Free Practice Tests & Premium Materials
SPOTO offers free, instant access to high-quality, up-to-date resources that help you study smarter and pass faster
✔️ Python, CCNA, CCNP, AWS, PMP, CISSP, Azure, & more
✔️ 100% Free, no sign-up, Instantly downloadable
📥Grab your free materials here:
·IT exams skill Test : https://bit.ly/443t4xB
·IT Certs E-book : https://bit.ly/4izDv1D
·Python, Excel, Cyber Security Courses : https://bit.ly/44LidZf
📱 Join Our IT Study Group for insider tips & expert support:
https://chat.whatsapp.com/K3n7OYEXgT1CHGylN6fM5a
💬 Need help ? Chat with an admin now:
wa.link/cbfsmf
⏳ Don’t Wait—Boost Your Career Today!
SPOTO offers free, instant access to high-quality, up-to-date resources that help you study smarter and pass faster
✔️ Python, CCNA, CCNP, AWS, PMP, CISSP, Azure, & more
✔️ 100% Free, no sign-up, Instantly downloadable
📥Grab your free materials here:
·IT exams skill Test : https://bit.ly/443t4xB
·IT Certs E-book : https://bit.ly/4izDv1D
·Python, Excel, Cyber Security Courses : https://bit.ly/44LidZf
📱 Join Our IT Study Group for insider tips & expert support:
https://chat.whatsapp.com/K3n7OYEXgT1CHGylN6fM5a
💬 Need help ? Chat with an admin now:
wa.link/cbfsmf
⏳ Don’t Wait—Boost Your Career Today!
❤2
✖️ DON'T CREATE NESTED LISTS WITH THE
Because of this, you create a list containing multiple references to the very same inner list.
It looks like you're making a grid, but modifying one row will surprisingly change all of them. This is because the outer list just holds copies of the reference, not copies of the list itself.
Correct — use a list comprehension to ensure each inner list is a new, independent object.
Subscribe for more Python secrets!
━━━━━━━━━━━━━━━
By: @DataScienceQ ✨
* OPERATOR.Because of this, you create a list containing multiple references to the very same inner list.
It looks like you're making a grid, but modifying one row will surprisingly change all of them. This is because the outer list just holds copies of the reference, not copies of the list itself.
Correct — use a list comprehension to ensure each inner list is a new, independent object.
Subscribe for more Python secrets!
# hidden error — all inner lists are the same object
matrix = [[]] * 3 # seems to create a 3x0 matrix
# append to the first row
matrix[0].append(99)
# all rows were modified!
print(matrix) # [[99], [99], [99]]
# ✅ correct version — use a list comprehension
matrix_fixed = [[] for _ in range(3)]
# append to the first row
matrix_fixed[0].append(99)
# only the first row is modified, as expected
print(matrix_fixed) # [[99], [], []]
━━━━━━━━━━━━━━━
By: @DataScienceQ ✨
❤5
🎁❗️TODAY FREE❗️🎁
Entry to our VIP channel is completely free today. Tomorrow it will cost $500! 🔥
JOIN 👇
https://t.iss.one/+MPpZ4FO2PHQ4OTZi
https://t.iss.one/+MPpZ4FO2PHQ4OTZi
https://t.iss.one/+MPpZ4FO2PHQ4OTZi
Entry to our VIP channel is completely free today. Tomorrow it will cost $500! 🔥
JOIN 👇
https://t.iss.one/+MPpZ4FO2PHQ4OTZi
https://t.iss.one/+MPpZ4FO2PHQ4OTZi
https://t.iss.one/+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.iss.one/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
❤2
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
❤6👍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
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.iss.one/+YDWOxSLvMfQ2MGNi
⚡️FREE ONLY FOR THE FIRST 500 SUBSCRIBERS! FURTHER ENTRY IS PAID! 👆👇
https://t.iss.one/+YDWOxSLvMfQ2MGNi
Everyone can join his channel and make money! He gives away from $200 to $5.000 every day in his channel
https://t.iss.one/+YDWOxSLvMfQ2MGNi
⚡️FREE ONLY FOR THE FIRST 500 SUBSCRIBERS! FURTHER ENTRY IS PAID! 👆👇
https://t.iss.one/+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
Data Setup
#### pandas
#### polars
#### SQL (Conceptual Table Structure and Data)
---
Select All Columns (
#### pandas
#### polars
#### SQL
---
Select Specific Columns (
#### pandas
#### polars
#### SQL
---
Select Unique Values (
#### pandas
#### polars
#### SQL
---
Filter Rows (
#### pandas
#### pandas
import pandas as pd
data = {
'product_id': [101, 102, 103, 104, 105, 106, 107],
'product_name': ['Laptop', 'Mouse', 'Keyboard', 'Monitor', 'Webcam', 'Microphone', 'Speakers'],
'category': ['Electronics', 'Electronics', 'Electronics', 'Electronics', 'Peripherals', 'Peripherals', 'Audio'],
'price': [1200.00, 25.00, 75.00, 300.00, 50.00, 80.00, 150.00],
'stock_quantity': [50, 200, 150, 70, 100, 60, 40]
}
df_pd = pd.DataFrame(data)
#### polars
import polars as pl
data = {
'product_id': [101, 102, 103, 104, 105, 106, 107],
'product_name': ['Laptop', 'Mouse', 'Keyboard', 'Monitor', 'Webcam', 'Microphone', 'Speakers'],
'category': ['Electronics', 'Electronics', 'Electronics', 'Electronics', 'Peripherals', 'Peripherals', 'Audio'],
'price': [1200.00, 25.00, 75.00, 300.00, 50.00, 80.00, 150.00],
'stock_quantity': [50, 200, 150, 70, 100, 60, 40]
}
df_pl = pl.DataFrame(data)
#### SQL (Conceptual Table Structure and Data)
-- CREATE TABLE products (
-- product_id INT PRIMARY KEY,
-- product_name VARCHAR(255),
-- category VARCHAR(255),
-- price DECIMAL(10, 2),
-- stock_quantity INT
-- );
-- INSERT INTO products VALUES
-- (101, 'Laptop', 'Electronics', 1200.00, 50),
-- (102, 'Mouse', 'Electronics', 25.00, 200),
-- (103, 'Keyboard', 'Electronics', 75.00, 150),
-- (104, 'Monitor', 'Electronics', 300.00, 70),
-- (105, 'Webcam', 'Peripherals', 50.00, 100),
-- (106, 'Microphone', 'Peripherals', 80.00, 60),
-- (107, 'Speakers', 'Audio', 150.00, 40);
---
Select All Columns (
SELECT *)#### pandas
# Select all columns
print(df_pd)
#### polars
# Select all columns
print(df_pl)
# Or explicitly select all columns:
# print(df_pl.select(pl.all()))
#### SQL
-- Select all columns
SELECT *
FROM products;
---
Select Specific Columns (
SELECT col1, col2)#### pandas
# Select 'product_name' and 'price'
print(df_pd[['product_name', 'price']])
#### polars
# Select 'product_name' and 'price'
print(df_pl.select('product_name', 'price'))
# Or using pl.col:
# print(df_pl.select(pl.col('product_name'), pl.col('price')))
#### SQL
-- Select product_name and price
SELECT product_name, price
FROM products;
---
Select Unique Values (
SELECT DISTINCT)#### pandas
# Select unique categories
print(df_pd['category'].unique())
# Select unique combinations of 'category' and 'price'
print(df_pd[['category', 'price']].drop_duplicates())
#### polars
# Select unique categories
print(df_pl.select('category').unique())
# Select unique combinations of 'category' and 'price'
print(df_pl.select('category', 'price').unique())
#### SQL
-- Select unique categories
SELECT DISTINCT category
FROM products;
-- Select unique combinations of category and price
SELECT DISTINCT category, price
FROM products;
---
Filter Rows (
WHERE)#### pandas
# Select products with price greater than 100
print(df_pd[df_pd['price'] > 100])
# Select products in 'Electronics' category
print(df_pd[df_pd['category'] == 'Electronics'])
# Select products in 'Electronics' category with stock less than 100
print(df_pd[(df_pd['category'] == 'Electronics') & (df_pd['stock_quantity'] < 100)])
#### polars
# Select products with price greater than 100
print(df_pl.filter(pl.col('price') > 100))
# Select products in 'Electronics' category
print(df_pl.filter(pl.col('category') == 'Electronics'))
# Select products in 'Electronics' category with stock less than 100
print(df_pl.filter((pl.col('category') == 'Electronics') & (pl.col('stock_quantity') < 100)))
#### SQL
-- Select products with price greater than 100
SELECT *
FROM products
WHERE price > 100;
-- Select products in 'Electronics' category
SELECT *
FROM products
WHERE category = 'Electronics';
-- Select products in 'Electronics' category with stock less than 100
SELECT *
FROM products
WHERE category = 'Electronics' AND stock_quantity < 100;
---
Order Rows (
ORDER BY)#### pandas
# Order products by price in ascending order
print(df_pd.sort_values('price'))
# Order products by price in descending order
print(df_pd.sort_values('price', ascending=False))
# Order by category (ASC) then by price (DESC)
print(df_pd.sort_values(by=['category', 'price'], ascending=[True, False]))
#### polars
# Order products by price in ascending order
print(df_pl.sort('price'))
# Order products by price in descending order
print(df_pl.sort('price', descending=True))
# Order by category (ASC) then by price (DESC)
print(df_pl.sort(by=['category', 'price'], descending=[False, True]))
#### SQL
-- Order products by price in ascending order
SELECT *
FROM products
ORDER BY price ASC;
-- Order products by price in descending order
SELECT *
FROM products
ORDER BY price DESC;
-- Order by category (ASC) then by price (DESC)
SELECT *
FROM products
ORDER BY category ASC, price DESC;
---
Limit Rows (
LIMIT)#### pandas
# Get the first 3 products
print(df_pd.head(3))
#### polars
# Get the first 3 products
print(df_pl.head(3))
# Or using limit:
# print(df_pl.limit(3))
#### SQL
-- Get the first 3 products
SELECT *
FROM products
LIMIT 3; -- Use TOP 3 for SQL Server: SELECT TOP 3 * FROM products;
---
Rename Columns (
AS)#### pandas
# Select 'product_name' as 'Item' and 'price' as 'Unit_Price'
print(df_pd[['product_name', 'price']].rename(columns={'product_name': 'Item', 'price': 'Unit_Price'}))
#### polars
# Select 'product_name' as 'Item' and 'price' as 'Unit_Price'
print(df_pl.select(
pl.col('product_name').alias('Item'),
pl.col('price').alias('Unit_Price')
))
#### SQL
-- Select product_name as Item and price as Unit_Price
SELECT product_name AS Item, price AS Unit_Price
FROM products;
---
Combined Operations (Filter, Select, Order, Limit)
#### pandas
# Select 'product_name', 'price', and 'stock_quantity' for 'Electronics' products,
# where price is > 50, ordered by 'price' descending, then get the top 2
result_pd = (
df_pd[df_pd['category'] == 'Electronics']
.loc[lambda df: df['price'] > 50]
[['product_name', 'price', 'stock_quantity']]
.sort_values(by='price', ascending=False)
.head(2)
)
print(result_pd)
#### polars
# Select 'product_name', 'price', and 'stock_quantity' for 'Electronics' products,
# where price is > 50, ordered by 'price' descending, then get the top 2
result_pl = (
df_pl.filter(pl.col('category') == 'Electronics')
.filter(pl.col('price') > 50)
.select('product_name', 'price', 'stock_quantity')
.sort('price', descending=True)
.head(2)
)
print(result_pl)
#### SQL
-- Select product_name, price, and stock_quantity for 'Electronics' products,
-- where price is > 50, ordered by price descending, then get the top 2
SELECT product_name, price, stock_quantity
FROM products
WHERE category = 'Electronics' AND price > 50
ORDER BY price DESC
LIMIT 2;
━━━━━━━━━━━━━━━
By: @DataScienceQ ✨