Some interesting libraries or modules…

 Python: Python is a popular programming language. Python is dynamically-typed and garbage-collected programming language. It was created by Guido van Rossum during 1985- 1990.

It is one of the world’s most popular, in-demand programming languages. Reasons:

  • It’s easy to learn.
  • It’s super versatile.
  • It has a huge range of modules and libraries.

Modules: A module is a collection of code or functions that uses the .py extension.

Libraries: A Python library is a set of related modules or packages bundled together.

Python provides some interesting modules and libraries.

  1. Pillow: It is a lightweight image processing tool that aid in editing, creating, and saving images. Pillow supports many image file formats including BMP, PNG, JPEG, and TIFF. Python Imaging Library is a free and open-source additional library for the Python programming language that adds support for opening, manipulating, and saving many different images file formats.

To install pillow: pip install Pillow


from PIL import Image


# open the Image
img = Image.open(r"mag.jpg")
print(img.size,img.format,img.mode)

# Display the Image
img.show()

# Crop the Image
box = (100,100,400,400)
region = img.crop(box)
region.show()

# Resize the Image
size = (40,40)
out = img.resize(size)
out.show()
from PIL import Image, ImageDraw
import glob

frames = []
imgs = glob.glob('*.jpg')
for i in imgs:
n_frame = Image.open(i)
frames.append(n_frame)

frames[0].save('Smily_gif.gif'.format('GIF'),
append_images = frames[0:],
save_all = True, duration = 300, loop=0)

2. Urllib: Urllib is the URL handling module for python. It is used to fetch URLs (Uniform Resource Locators). The Python urllib module allows us to access the website via Python code. It uses the urlopen function and is able to fetch URLs using a variety of different protocols.

To install urllib: pip install urllib

3. Turtle: Turtle graphics is a popular way for introducing programming to kids. Turtle is a Python feature like a drawing board, which lets us command a turtle to draw all over it! We can use functions like turtle.forward( ) turtle.right( ) which can move the turtle around.

import turtle

wn = turtle.Screen()
wn.bgcolor("pink")
wn.title("Turtle")
skk = turtle.Turtle()
skk.forward(100)
turtle.done()

Draw a star using turtle:

import turtle
star = turtle.Turtle()

star.right(75)
star.forward(100)

for i in range(4):
star.right(144)
star.forward(100)

turtle.done()

Draw Spiral Helix pattern:

import turtle
loadWindow = turtle.Screen()
turtle.speed(2)

for i in range(100):
turtle.circle(5*i)
turtle.circle(-5*i)
turtle.left(i)

turtle.exitonclick()

4. art: The art used to decorative text on the console as well as to save in file.

To install art: pip install art

a. Using art() function:

syntax: art ( name of art, number is integer denoting number of arts in string )

from art import *

art__0 = art("woman",number=10) # return art as str in normal mode
art__1 = art("coffee") # return art as str in normal mode
art__2 = art("rand") # random 1-line art mode
art__3 = art("random") # random 1-line art mode

print(art__0)
print(art__1)
print(art__2)
print(art__3)

b. Using aprint() function: Directly print arts just like the print function you print something.

from art import *

aprint("butterfly") # print art
aprint("happy") # print art
aprint("random") # random 1-line art mode

c. Using text2art() function: This function ASCII text as str in normal mode.

from art import *

Art = text2art("Pratiksha") # Return ASCII text (default font) and default chr_ignore=True
print(Art)

Art1 = text2art("Pratiksha",font='block',chr_ignore=True) # Return ASCII text with block font
print(Art1)

Art2 = text2art("Pratiksha","random") # random font mode
print(Art2)

d. Using tprint() function: It is same as print() function, which is used to print text into ASCII FORMAT.

from art import *

tprint("hi")
tprint("HI","rnd-xlarge")

e. Using tsave() function: This function used to save ASCII text into file.

from art import *
tsave("Pratiksha's Work",filename="test.txt")
ART_NAMES  # To access all arts name list
NON_ASCII_ARTS # To access all Non-ASCII arts name list
ASCII_ARTS # to access all ASCII arts name list

5. pyaztro: Pyaztro library is provides horoscope info of any zodiac sign for that day etc.

To install pyaztro: pip install pyaztro

import pyaztro

horoscope = pyaztro.Aztro(sign='virgo')
print(
'Sign:', horoscope.sign, '\n',
'Current date:', horoscope.current_date, '\n',
'Date range:', horoscope.date_range, '\n',
'Sign description:', horoscope.description, '\n',
'Mood:', horoscope.mood, '\n',
'Compatibility:', horoscope.compatibility, '\n',
'Lucky number:', horoscope.lucky_number, '\n',
'Lucky time:', horoscope.lucky_time, '\n',
'Lucky color:', horoscope.color, 2*'\n',
'Description:', horoscope.description
)




Blog: Thank you 😊 for reading. Please read other blogs. And also share with your friends and family.

Comments

Popular posts from this blog

How to convert PDF file into audio file?

Pillow Libary in Python.

How to perform operations on emails and folders using imap_tools?