Python Projects & Resources
57.5K subscribers
779 photos
342 files
330 links
Perfect channel to learn Python Programming 🇮🇳
Download Free Books & Courses to master Python Programming
- Free Courses
- Projects
- Pdfs
- Bootcamps
- Notes

Admin: @Coderfun
Download Telegram
🖥 10 Advanced Python Scripts For Everyday Programming

1. SpeedTest with Python
# pip install pyspeedtest
# pip install speedtest
# pip install speedtest-cli

#method 1
import speedtest

speedTest = speedtest.Speedtest()
print(speedTest.get_best_server())

#Check download speed
print(speedTest.download())

#Check upload speed
print(speedTest.upload())

# Method 2

import pyspeedtest
st = pyspeedtest.SpeedTest()
st.ping()
st.download()
st.upload()

2. Search on Google

# pip install google

from googlesearch import search

query = "Medium.com"

for url in search(query):
print(url)


3. Make Web Bot
# pip install selenium

import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys

bot = webdriver.Chrome("chromedriver.exe")
bot.get('[https://www.google.com'](https://www.google.com'))

search = bot.find_element_by_name('q')
search.send_keys("@codedev101")
search.send_keys(Keys.RETURN)
time.sleep(5)
bot.quit()


4. Fetch Song Lyrics
# pip install lyricsgenius

import lyricsgenius

api_key = "xxxxxxxxxxxxxxxxxxxxx"

genius = lyricsgenius.Genius(api_key)
artist = genius.search_artist("Pop Smoke", max_songs=5,sort="title")
song = artist.song("100k On a Coupe")

print(song.lyrics)


5. Get Exif Data of Photos
# Get Exif of Photo

# Method 1
# pip install pillow
import PIL.Image
import PIL.ExifTags

img = PIL.Image.open("Img.jpg")
exif_data =
{
PIL.ExifTags.TAGS[i]: j
for i, j in img._getexif().items()
if i in PIL.ExifTags.TAGS
}
print(exif_data)


# Method 2
# pip install ExifRead
import exifread

filename = open(path_name, 'rb')

tags = exifread.process_file(filename)
print(tags)


6. OCR Text from Image
# pip install pytesseract

import pytesseract
from PIL import Image

pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe'

t=Image.open("img.png")
text = pytesseract.image_to_string(t, config='')

print(text)


7. Convert Photo into Cartonize

# pip install opencv-python

import cv2

img = cv2.imread('img.jpg')
grayimg = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
grayimg = cv2.medianBlur(grayimg, 5)

edges = cv2.Laplacian(grayimg , cv2.CV_8U, ksize=5)
r,mask =cv2.threshold(edges,100,255,cv2.THRESH_BINARY_INV)

img2 = cv2.bitwise_and(img, img, mask=mask)
img2 = cv2.medianBlur(img2, 5)

cv2.imwrite("cartooned.jpg", mask)


8. Empty Recycle Bin
# pip install winshell

import winshell
try:
winshell.recycle_bin().empty(confirm=False, /show_progress=False, sound=True)
print("Recycle bin is emptied Now")
except:
print("Recycle bin already empty")


9. Python Image Enhancement
# pip install pillow

from PIL import Image,ImageFilter
from PIL import ImageEnhance

im = Image.open('img.jpg')

# Choose your filter
# add Hastag at start if you don't want to any filter below

en = ImageEnhance.Color(im)
en = ImageEnhance.Contrast(im)
en = ImageEnhance.Brightness(im)
en = ImageEnhance.Sharpness(im)

# result
en.enhance(1.5).show("enhanced")


10. Get Window Version
# Window Version

import wmi
data = wmi.WMI()
for os_name in data.Win32_OperatingSystem():
print(os_name.Caption) # Microsoft Windows 11 Home
👍162🔥1🥰1
📩 Python Email Automation Script

import smtplib
from email.mime.text import MIMEText


sender_email = "[email protected]"
recipient_email = "[email protected]"

subject = "Automated Email"
message = "This is an automated email sent using Python."


# SMTP server configuration (example: Gmail)


smtp_server = "smtp.gmail.com"
smtp_port = 587
smtp_username = "your_username"
smtp_password = "your_password"



msg = MIMEText(message)
msg["Subject"] = subject
msg["From"] = sender_email
msg["To"] = recipient_email
try:

server = smtplib.SMTP(smtp_server, smtp_port)
server.starttls()
server.login(smtp_username, smtp_password)
server.sendmail(sender_email, recipient_email, msg.as_string())
print("Email sent successfully!")

except Exception as e:
print("Error sending email:", str(e))

finally:

server.quit()
👍122
COMMON TERMINOLOGIES IN PYTHON - PART 1

Have you ever gotten into a discussion with a programmer before? Did you find some of the Terminologies mentioned strange or you didn't fully understand them?

In this series, we would be looking at the common Terminologies in python.

It is important to know these Terminologies to be able to professionally/properly explain your codes to people and/or to be able to understand what people say in an instant when these codes are mentioned. Below are a few:

IDLE (Integrated Development and Learning Environment) - this is an environment that allows you to easily write Python code. IDLE can be used to execute a single statements and create, modify, and execute Python scripts.

Python Shell - This is the interactive environment that allows you to type in python code and execute them immediately

System Python - This is the version of python that comes with your operating system

Prompt - usually represented by the symbol ">>>" and it simply means that python is waiting for you to give it some instructions

REPL (Read-Evaluate-Print-Loop) - this refers to the sequence of events in your interactive window in form of a loop (python reads the code inputted>the code is evaluated>output is printed)

Argument - this is a value that is passed to a function when called eg print("Hello World")... "Hello World" is the argument that is being passed.

Function - this is a code that takes some input, known as arguments, processes that input and produces an output called a return value. E.g print("Hello World")... print is the function

Return Value - this is the value that a function returns to the calling script or function when it completes its task (in other words, Output). E.g.
>>> print("Hello World")
Hello World
Where Hello World is your return value.

Note: A return value can be any of these variable types: handle, integer, object, or string

Script - This is a file where you store your python code in a text file and execute all of the code with a single command

Script files - this is a file containing a group of python scripts
👍132
Python Code to Display Calendar 🗓️ : 👇👇👇

import calendar
# Enter the month and year
yy = int(input("Enter year: "))
mm = int(input("Enter month: "))

# display the calendar
print(calendar.month(yy,mm))
👍32🔥1
Important Methods in Python Programming
Google Interview Guide.pdf
1.4 MB
Google Interview Guide.pdf
👍3
PYTHON INTRO

Python is a high-level, interpreted programming language that was created by Guido van Rossum and released in 1991. It is a popular language for a wide range of applications, including web development, scientific computing, data analysis, artificial intelligence, and more.

Python is known for its simple syntax and readability, which make it easy for beginners to learn and write code. It has a large and active community of users and developers, who have created a vast ecosystem of libraries, frameworks, and tools that make it easy to accomplish complex tasks with relatively little code.

Python is an interpreted language, meaning that code is executed line-by-line at runtime rather than being compiled into machine code. This can make it slower than compiled languages like C or Java, but also makes it more flexible and easier to debug.

Python's standard library includes modules for a wide range of tasks, such as file input/output, networking, and regular expressions. Additionally, there are thousands of third-party modules available through the Python Package Index (PyPI) that can be installed with a simple command using Python's package manager, pip.
👍6
WHAT CAN PYTHON DO ?

Python is a versatile programming language that can be used for a wide range of tasks, including:

1. Web development: Python can be used to build dynamic and interactive web applications using popular frameworks such as Django and Flask.

2. Data analysis and visualization: Python has numerous libraries for data analysis, scientific computing, and visualization, such as NumPy, pandas, and Matplotlib.

3. Machine learning and artificial intelligence: Python is one of the most popular languages for machine learning and AI development, with popular libraries such as scikit-learn, TensorFlow, and PyTorch.

4. Scripting and automation: Python's simple syntax and ease of use make it ideal for scripting and automating tasks, such as managing files and folders, sending emails, and performing system maintenance tasks.

5. Game development: Python has several game development libraries and frameworks, including Pygame and Panda3D.

6. Desktop applications: Python can be used to develop desktop applications with user interfaces using popular libraries such as Tkinter, PyQt, and wxPython.
👍5