How to easily blur any image using PIL
🟡 In general, the PIL library has a lot of features and excellent documentation
#library
#python
🆔 @Python4all_pro
from PIL import Image, ImageFilter
def blur_image(image_path, output_path, radius):
image = Image.open(image_path)
blurred_image = image.filter(ImageFilter.GaussianBlur(radius))
blurred_image.save(output_path)
blur_image('cat.jpg', 'cat_out.jpg', 3)
Image.open('cat_out.jpg')
🟡 In general, the PIL library has a lot of features and excellent documentation
#library
#python
🆔 @Python4all_pro
🖥 چگونه با استفاده از پایتون متن مخفی را در داخل یک عکس پنهان کنیم؟
هیچ چیز پیچیده ای نیست، فقط به کتابخانه Stegano نیاز دارید
🖥 GitHub
#library
#python
🆔 @Python4all_pro
هیچ چیز پیچیده ای نیست، فقط به کتابخانه Stegano نیاز دارید
# pip install stegano
from stegano import lsb
secret = lsb.hide('image.png', 'очень секретный текст')
secret.save('secret_image.png')
print(lsb.reveal('secret_image.png'))
🖥 GitHub
#library
#python
🆔 @Python4all_pro
حل سوالات استخدامی سایت leetcode.com
Problem: No. 18. 4Sum #medium
Condition:
Given an array nums of n integers, return an array of all unique quadruples [nums[a], nums[b], nums[c], nums[d]] such that:
0 <= a, b, c, d < n
a, b, c and d are different.
nums[a] + nums[b] + nums[c] + nums[d] == target
You can return the response in any order.
Solution:
Explanation:
Sorting:
First the nums array is sorted. Sorting makes it easier to handle duplicates and speeds up execution using binary search.
Recursive function findNsum:
The findNsum function recursively finds combinations whose sum is equal to the given target. Depending on the value of N, it handles different cases:
For N = 2: This is the "Two Sum" subtask. We use two pointers (l and r) to find pairs of numbers in the array that add up to target.
If the current pair of numbers nums[l] and nums[r] sums to target, add this pair to the results.
We move the pointers left and right, skipping duplicates to avoid repeated combinations.
For N > 2: The function calls itself recursively, decrementing N by 1 and continuing to search for combinations among the remaining elements of the array. We also check if the current element and its combinations are within a valid range (for optimization).
Conditions for exiting recursion:
If the length of the array is less than N or N is less than 2, the function terminates execution, since there is no point in further searching for combinations.
We use conditions to stop execution if the current element is too large or too small to achieve the target value for a given number of elements (N).
Unique combinations:
To avoid duplicates, we check whether the current element is unique compared to previous ones.
Collection of results:
The results for each call to the findNsum function are added to the results list.
#interview #LeetCode
🆔 @Python4all_pro
Problem: No. 18. 4Sum #medium
Condition:
Given an array nums of n integers, return an array of all unique quadruples [nums[a], nums[b], nums[c], nums[d]] such that:
0 <= a, b, c, d < n
a, b, c and d are different.
nums[a] + nums[b] + nums[c] + nums[d] == target
You can return the response in any order.
Solution:
nums.sort()
results = []
self.findNsum(nums, target, 4, [], results)
return results
def findNsum(self, nums, target, N, result, results):
if len(nums) < N or N < 2: return
# solve 2-sum
if N == 2:
l,r = 0,len(nums)-1
while l < r:
if nums[l] + nums[r] == target:
results.append(result + [nums[l], nums[r]])
l += 1
r -= 1
while l < r and nums[l] == nums[l - 1]:
l += 1
while r > l and nums[r] == nums[r + 1]:
r -= 1
elif nums[l] + nums[r] < target:
l += 1
else:
r -= 1
else:
for i in range(0, len(nums)-N+1): # careful about range
if target < nums[i]*N or target > nums[-1]*N: # take advantages of sorted list
break
if i == 0 or i > 0 and nums[i-1] != nums[i]: # recursively reduce N
self.findNsum(nums[i+1:], target-nums[i], N-1, result+[nums[i]], results)
return
Explanation:
Sorting:
First the nums array is sorted. Sorting makes it easier to handle duplicates and speeds up execution using binary search.
Recursive function findNsum:
The findNsum function recursively finds combinations whose sum is equal to the given target. Depending on the value of N, it handles different cases:
For N = 2: This is the "Two Sum" subtask. We use two pointers (l and r) to find pairs of numbers in the array that add up to target.
If the current pair of numbers nums[l] and nums[r] sums to target, add this pair to the results.
We move the pointers left and right, skipping duplicates to avoid repeated combinations.
For N > 2: The function calls itself recursively, decrementing N by 1 and continuing to search for combinations among the remaining elements of the array. We also check if the current element and its combinations are within a valid range (for optimization).
Conditions for exiting recursion:
If the length of the array is less than N or N is less than 2, the function terminates execution, since there is no point in further searching for combinations.
We use conditions to stop execution if the current element is too large or too small to achieve the target value for a given number of elements (N).
Unique combinations:
To avoid duplicates, we check whether the current element is unique compared to previous ones.
Collection of results:
The results for each call to the findNsum function are added to the results list.
#interview #LeetCode
🆔 @Python4all_pro
ربات پولساز تلگرام : #استارز
⭐️از طریق major که مینی اپ جدید و رسمی تلگرام میباشد قادر به جمع کردن ستاره خواهید بود.
✍🏼 در آخرین آپدیت تلگرام ، این مسنجر سیستم پرداخت جدیدش که Starts یا ستارهها نام دارد را راهاندازی کرد. با خرید ستاره از طریق اپ استور میتوان پستهای پولی کانالها را خرید، در رباتها پرداخت انجام داد و ...
❇️بجای خرید ستاره از اپاستور، با استفاده از مینی اپ جدید major قادر به دریافت ستاره خواهید بود. در آینده می توان ستارههای جمع آوری شده را به TON Coin تبدیل کرد یا از آنها برای خرید اشتراک پریمیوم تلگرام یا موارد دیگر استفاده کرد. پیشنهاد میکنیم که حتما این مینی اپ را استارت کنید و با دعوت دوستان ستاره جمع کنید.
با این لینک دعوت ۱۵ تا ستاره رایگان دریافت میکنید
با انجام دادن ۳ تسک ربات جمعا 170 استارز رایگان دریافت خواهید کرد
1. کیف پول تون رو بهش وصل کنید
2. ایکس رو چک کنید
3. عضو کانالش بشید
لینک شروع
👇👇
https://t.me/major/start?startapp=84219249
🆔 @Python4all_pro
⭐️از طریق major که مینی اپ جدید و رسمی تلگرام میباشد قادر به جمع کردن ستاره خواهید بود.
✍🏼 در آخرین آپدیت تلگرام ، این مسنجر سیستم پرداخت جدیدش که Starts یا ستارهها نام دارد را راهاندازی کرد. با خرید ستاره از طریق اپ استور میتوان پستهای پولی کانالها را خرید، در رباتها پرداخت انجام داد و ...
❇️بجای خرید ستاره از اپاستور، با استفاده از مینی اپ جدید major قادر به دریافت ستاره خواهید بود. در آینده می توان ستارههای جمع آوری شده را به TON Coin تبدیل کرد یا از آنها برای خرید اشتراک پریمیوم تلگرام یا موارد دیگر استفاده کرد. پیشنهاد میکنیم که حتما این مینی اپ را استارت کنید و با دعوت دوستان ستاره جمع کنید.
با این لینک دعوت ۱۵ تا ستاره رایگان دریافت میکنید
با انجام دادن ۳ تسک ربات جمعا 170 استارز رایگان دریافت خواهید کرد
1. کیف پول تون رو بهش وصل کنید
2. ایکس رو چک کنید
3. عضو کانالش بشید
لینک شروع
👇👇
https://t.me/major/start?startapp=84219249
🆔 @Python4all_pro
learneverythingai .pdf
3.8 MB
🖥 zarr - Python library for implementing compressed N-dimensional arrays
- pip install zarr
Zarr provides classes and functions for working with N-dimensional arrays, which behave like #NumPy arrays, but the data is divided into chunks and each chunk is compressed. If anyone is familiar with HDF5, Zarr arrays provide similar functionality, but they are more convenient.
Also, unlike HDF5, Zarr has better multithreading support.
🟡 Docks
🖥 GitHub
#library
#python
🆔 @Python4all_pro
- pip install zarr
Zarr provides classes and functions for working with N-dimensional arrays, which behave like #NumPy arrays, but the data is divided into chunks and each chunk is compressed. If anyone is familiar with HDF5, Zarr arrays provide similar functionality, but they are more convenient.
Also, unlike HDF5, Zarr has better multithreading support.
🟡 Docks
🖥 GitHub
#library
#python
🆔 @Python4all_pro
حل سوالات استخدامی سایت leetcode.com
Problem: No. 19. Remove Nth Node From End of List #medium
Condition:
Given the header of a linked list, remove the nth node from the end of the list and return its header
Solution:
Explanation:
Determining the list size:
First we go through the entire list to find its size. This is necessary to determine which node needs to be removed.
The size variable keeps track of the number of nodes in the list.
Removing the first node:
If n is equal to the size of the list, it means the first node should be removed. In this case, we return the next node from the head of the list.
Search for a node before the one you want to delete:
If n is not equal to the size of the list, we need to find the node that comes before the nth node from the end. We do this by moving size-n-1 nodes forward in the list.
Removing a node:
We set the next node for the found node so that it points to the next node after the next one, effectively bypassing the node to be deleted.
Returning a new header:
Returning the head of the list. If the first node was deleted, the new header will be the starting node of the list after the delete.
Time and space complexity:
Time complexity: O(L), where L is the length of the list. We go through the list twice: once to count nodes and again to remove a node.
Space complexity: O(1) because we use a constant amount of extra space independent of the size of the input data.
#Code
#interview #LeetCode
🆔 @Python4all_pro
Problem: No. 19. Remove Nth Node From End of List #medium
Condition:
Given the header of a linked list, remove the nth node from the end of the list and return its header
Solution:
# class ListNode:
# def init(self, x):
# self.val = x
# self.next = None
class Solution:
def removeNthFromEnd(self, head: ListNode, n: int) -> ListNode:
if head.next == None:
return None
tmp = head
size = 0
# find the size of the linked list
while tmp:
size += 1
tmp = tmp.next
tmp = head
#if we have to remove the first node:
if n == size:
return head.next
for i in range(size-n-1):
tmp = tmp.next
tmp.next = tmp.next.next
return head
Explanation:
Determining the list size:
First we go through the entire list to find its size. This is necessary to determine which node needs to be removed.
The size variable keeps track of the number of nodes in the list.
Removing the first node:
If n is equal to the size of the list, it means the first node should be removed. In this case, we return the next node from the head of the list.
Search for a node before the one you want to delete:
If n is not equal to the size of the list, we need to find the node that comes before the nth node from the end. We do this by moving size-n-1 nodes forward in the list.
Removing a node:
We set the next node for the found node so that it points to the next node after the next one, effectively bypassing the node to be deleted.
Returning a new header:
Returning the head of the list. If the first node was deleted, the new header will be the starting node of the list after the delete.
Time and space complexity:
Time complexity: O(L), where L is the length of the list. We go through the list twice: once to count nodes and again to remove a node.
Space complexity: O(1) because we use a constant amount of extra space independent of the size of the input data.
#Code
#interview #LeetCode
🆔 @Python4all_pro
🖥 badjpg
This useful Python script allows you to hide useful information inside a JPG image using steganography techniques.
▪ Github
#library
#python
🆔 @Python4all_pro
This useful Python script allows you to hide useful information inside a JPG image using steganography techniques.
▪ Github
git clone https://github.com/basicW/badjpg.git
#library
#python
🆔 @Python4all_pro
Forwarded from تهران دیتا-دانشگاه تهران
سی اُمین دوره جامع علم داده کل کشور
با تدریس مطرحترین اساتید دیتایی
آموزش ۱۵ سرفصل و ۱۲ نرم افزار و کاملا پروژه محور
همراه با
ارائه گواهی معتبر دوزبانه و تحت نظارت وزارت علوم با قابلیت ترجمه رسمی و امکان استعلام از دانشگاه تهران
اطلاعات بیشتر
Please open Telegram to view this post
VIEW IN TELEGRAM
دوره جامع تخصصی فرانت اند اینجاست 💪
از صفر تا متخصص یو آی یو ایکس و فرانت اند با شماییم
✴️ برای یک طراح سایت خوب در تمام دنیا جا هست.
◀️ اگر میخوای این مهارت رو به صورت حرفهای یاد بگیری این دوره مناسبته
‼️ اولین اولترا دوره طراحی و توسعه وبسایت با پشتیبانی اختصاصی رو از دست ندید
♨️ این دوره پیش نیاز ندارد
👇👇👇👇
https://zaya.io/z4nra
📌 ثبت نام دوره
از صفر تا متخصص یو آی یو ایکس و فرانت اند با شماییم
✴️ برای یک طراح سایت خوب در تمام دنیا جا هست.
◀️ اگر میخوای این مهارت رو به صورت حرفهای یاد بگیری این دوره مناسبته
‼️ اولین اولترا دوره طراحی و توسعه وبسایت با پشتیبانی اختصاصی رو از دست ندید
♨️ این دوره پیش نیاز ندارد
👇👇👇👇
https://zaya.io/z4nra
📌 ثبت نام دوره