pip install xlsxwriter pydub pillow moviepy requests click
- Tech Lead, Full-Stack & DevOps - @Appknox
- I code for Web, Mobile, Embedded & IoT. Open-Source Fanatic. Big Data & Machine Learning Enthusiast. Dad. Atheist
- So primarily a Developer + little bit of this & that
- Jack of all trades & Master of none
- No, I do not keep Bindi for religious reasons. Its for a scientific reason & a fashion statement.
- http://dhilipsiva.com
- [email protected]
- Dropout (Yes, I am not a graduate)
- Startup Fanatic (& hate corporate)
- Full Stack & DevOps landscape
- Getting Started on ML
- I love Python. A lot.
- Take my words with a pinch of salt
None, Boolean, Numbers, Strings, List, Tuple, Set, Dict, Variables, List & String Manipulation, Conditionals, Loops, Function
More: https://github.com/ChillarAnand/python-101/blob/master/manuscript.md
- Files (Text, Excel, Audio, Image, Video)
- Classes & Objects
- CLI Application (Let's build a simple game)
fr = open("file.txt") # Open a file to read
fr.read() # Will read entire content
fr.readline() # Reads line by line
fr.readlines() # Reads the entire files and return a list
fr.close() # Close the file
fw = open("file.txt", "w") # Open a file to write
fw.write("Foo Bar") # Write a single line
fw.writelines(["One", "Two"]) # Write a list of lines
fw.close() # Close the file
# Also explain append mode
- Copy content of one file into another file
- Remove the lines in a file which has the text
foo
import xlsxwriter
workbook = xlsxwriter.Workbook('demo.xlsx')
worksheet = workbook.add_worksheet()
worksheet.set_column('A:A', 20)
bold = workbook.add_format({'bold': True})
worksheet.write('A1', 'Hello')
worksheet.write('A2', 'World', bold)
worksheet.write(2, 0, 123)
worksheet.write(3, 0, 123.456)
worksheet.insert_image('B5', 'logo.png')
workbook.close()
from PIL import ImageFilter
size = (128, 128)
from PIL import Image
im = Image.open("lena.ppm")
print(im.format, im.size, im.mode)
im.show()
im.thumbnail(size)
box = (100, 100, 400, 400)
region = im.crop(box)
region = region.transpose(Image.ROTATE_180)
out = im.resize((128, 128))
out = im.rotate(45)
out = im.transpose(Image.FLIP_LEFT_RIGHT)
out = im.filter(ImageFilter.DETAIL)
from pydub import AudioSegment
song = AudioSegment.from_wav("trance.wav")
ten_seconds = 10 * 1000
first_10_seconds = song[ten_seconds:ten_seconds*2]
last_5_seconds = song[-5000:]
beginning = first_10_seconds + 6
end = last_5_seconds - 3
backwards = beginning.reverse()
with_style = beginning.append(end, crossfade=1500)
with_style = with_style.append(backwards, crossfade=1500)
do_it_over = with_style * 2
awesome = do_it_over.fade_in(2000).fade_out(3000)
awesome.export("mashup.wav", format="wav")
from moviepy.editor import VideoFileClip, TextClip, CompositeVideoClip
clip = VideoFileClip("baby-cry.webm")
clip = clip.volumex(0.8)
txt_clip = TextClip("Baby Cry", fontsize=70, color='white')
txt_clip = txt_clip.set_pos('center').set_duration(3)
video = CompositeVideoClip([clip, txt_clip])
video.write_videofile("baby-cry-text.webm")
- Abstraction
- Polymorphism
- Encapsulation
- Inheritance
__init__, super, __str__, __len__
Lets build a simple game, shall we?
This copy is released under the MIT License