Learn Python
111K subscribers
388 photos
9 videos
781 files
118 links
Download and watch the best premium Python Courses.

Buy ads: https://telega.io/c/LearnPython3
Download Telegram
🖥 Turn (almost) any Python command line program into a full GUI application with one line.

🔗 GitHub: https://github.com/chriskiehl/Gooey

https://t.me/LearnPython3

More Likes, Share, Subscribe 😉
🔥30👍229
🔅 Scan for open ports
from socket import *
import time
startTime = time.time()

if __name__ == '__main__':
target = input('Enter the host to be scanned: ')
t_IP = gethostbyname(target)
print ('Starting scan on host: ', t_IP)

for i in range(1, 10000):
s = socket(AF_INET, SOCK_STREAM)
conn = s.connect_ex((t_IP, i))
if(conn == 0) :
print ('Port %d: OPEN' % (i,))
s.close()
print('Time taken:', time.time() - startTime)
🔥23👍1712😁1
🔅 Fetch Open Ports
🔥158👍7
🔅 Compress Images

from PIL import Image

# https://t.me/LearnPython3

in_img = 'input.png'
out_img = 'compressed.png'

# Open the image
with Image.open(in_img) as img:
# Save the compressed image
img.save(out_img, 'PNG', quality=80)

print(f"Image compressed successfully!")
24👍12🔥8
🔅 Compress Images
38👍9🔥5
🔅 Extract the colors and their codes from an image

from PIL import Image
from collections import Counter

# https://t.me/LearnPython3

# Open the image
image = Image.open('input.png')

# Convert the image to a list of RGB tuples
pixels = list(image.getdata())

# Use Counter to count the occurrences of each color
color_counts = Counter(pixels)

# Get the 6 most common colors
top_colors = color_counts.most_common(6)

# Print the extracted colors and their counts
for i, (color, count) in enumerate(top_colors):
color_block = "\033[48;2;{};{};{}m \033[0m".format(color[0], color[1], color[2])
print(f"Color {i + 1}: {color_block} RGB: {color} - Count: {count}")
👍2710🔥10👏1
🔅 Extract the colors and their codes from an image
👌229👍9
🔅 Merge PDFs

pip install PyPDF2


from PyPDF2 import PdfFileMerger

# https://t.me/LearnPython3

# By appending in the end
def by_appending():
merger = PdfFileMerger()
# Either provide file stream
f1 = open("samplePdf1.pdf", "rb")
merger.append(f1)
# Or direct file path
merger.append("samplePdf2.pdf")

merger.write("mergedPdf.pdf")


# By inserting at after an specified page no.
def by_inserting():
merger = PdfFileMerger()
merger.append("samplePdf1.pdf")
merger.merge(0, "samplePdf2.pdf")
merger.write("mergedPdf1.pdf")


if __name__ == "__main__":
by_appending()
by_inserting()


@LearnPython3
👍3917🔥5👎2
🔅 Merge PDFs
16👍6
🔅 Merge PDFs
👍20🤯105👏3
What is the difference between a module and a package?
24👍6👏5
🚀 Alright, let's talk about modules and packages in Python.

A module is like a file that contains Python code. It can have functions, classes, or variables. When you want to use something from a module, you import it using the import keyword. Simple, right? 🤓

Now, a package is a way to organize related modules into a directory hierarchy. Think of it as a collection of modules bundled together. To make a directory a package, you just need to include a special file called __init__.py in it.

So, in simple terms, a module is a single file with Python code, and a package is a collection of modules organized in a directory. Modules are like building blocks, and packages are like containers holding those blocks. Easy, isn't it? 🧩
👏4723👍18🔥10
🔅Quick Guide On Pandas

@LearnPython3
👍6821🔥9🥰6
🔰 Learn Python 3.9 | Start your Programming Career in 4 Hours

🌟 4.0 - 36 votes 💰 Original Price: $29.99

Learn Python in just 4 hours! Master the fundamentals, build practical skills, and start coding with this course


Taught By: CyberSkill Academy

Download Full Course: https://t.me/LearnPython3/894
Download All Courses: https://t.me/zero_to_mastery
👍4612👏6🤗5