.
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## PythonScriptPH 🇵🇭
2 |
3 | [](#contributors-)
4 |
5 |
6 |  
7 |
8 | [](https://www.python.org/) [](https://www.gnu.org/licenses/gpl-3.0.en.html)
9 |
10 | ---
11 |
12 | ### 🦚 Available Scripts
13 |
14 | - [Algorithms](https://github.com/mpotane/PythonScriptPH/tree/main/Algorithms)
15 | - [Searching](https://github.com/mpotane/PythonScriptPH/tree/main/Algorithms/Searching)
16 | - [Sorting](https://github.com/mpotane/PythonScriptPH/tree/main/Algorithms/Sorting)
17 | - [Btc To Php](https://github.com/mpotane/PythonScriptPH/tree/main/btc-to-php)
18 | - [Compress Photo](https://github.com/mpotane/PythonScriptPH/tree/main/compress-photo)
19 | - [Csv To Excel](https://github.com/mpotane/PythonScriptPH/tree/main/csv-to-excel)
20 | - [Csv To Json](https://github.com/mpotane/PythonScriptPH/tree/main/csv-to-json)
21 | - [Detect Language](https://github.com/mpotane/PythonScriptPH/tree/main/detect-language)
22 | - [Filecopy](https://github.com/mpotane/PythonScriptPH/tree/main/filecopy)
23 | - [Img To Pdf](https://github.com/mpotane/PythonScriptPH/tree/main/img-to-pdf)
24 | - [Json To YAML](https://github.com/mpotane/PythonScriptPH/tree/main/json-to-yaml)
25 | - [Pdf to docx](https://github.com/mpotane/PythonScriptPH/tree/main/pdf-to-docx)
26 | - [Philippine Flag](https://github.com/mpotane/PythonScriptPH/tree/main/Philippine-flag)
27 | - [Proof Reader](https://github.com/mpotane/PythonScriptPH/tree/main/proof-reader)
28 | - [Qrcode](https://github.com/mpotane/PythonScriptPH/tree/main/qrcode)
29 | - [Remove Background Image](https://github.com/mpotane/PythonScriptPH/tree/main/remove-background-image)
30 | - [Speed Test](https://github.com/mpotane/PythonScriptPH/tree/main/speed-test)
31 | - [Text To Tagalog](https://github.com/mpotane/PythonScriptPH/tree/main/text-to-tagalog)
32 | - [Usd To Peso](https://github.com/mpotane/PythonScriptPH/tree/main/usd-to-peso)
33 | - [Youtube Video Downloader](https://github.com/mpotane/PythonScriptPH/tree/main/youtube-video-downloader)
34 |
35 | ---
36 |
37 | ### 🎯 Contribute
38 |
39 | Open for contributions. Create a pull request and I will review the code. [Contributor Guide](./CODE_OF_CONDUCT.md) 🧐
40 |
41 | ### 📋 Code of Conduct
42 | This project and everyone participating in it are governed by the [Contributor Covenant Code of Conduct](./CODE_OF_CONDUCT.md). By participating, you agree to abide by this code of conduct.
43 |
44 | ---
45 |
46 | ## Contributors ✨
47 |
48 |
49 |
50 |
51 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | Thanks goes to these wonderful people! 🙏
81 |
--------------------------------------------------------------------------------
/algorithms/Searching/bin_search.py:
--------------------------------------------------------------------------------
1 | def bin_search(li,x):
2 |
3 | l=0
4 | u=len(li)-1
5 | m=(l+u)//2
6 | while li[m]==x or l<=u:
7 |
8 |
9 | if li[m]==x:
10 | return m
11 |
12 | elif xl[j+1]:
5 | l[j],l[j+1]=l[j+1],l[j]
6 |
7 |
8 | print(l)
9 |
--------------------------------------------------------------------------------
/algorithms/Sorting/insertion_sort.py3:
--------------------------------------------------------------------------------
1 | def insertion_sort(l):
2 | for i in range(1,len(l)):
3 | temp=l[i]
4 | j=i-1
5 | while(j>=0 and temp sample.yaml
--------------------------------------------------------------------------------
/json-to-yaml/requirements.txt:
--------------------------------------------------------------------------------
1 | pyyaml
--------------------------------------------------------------------------------
/json-to-yaml/sample.json:
--------------------------------------------------------------------------------
1 | {
2 | "name" : { "0": "John Doe", "1": "Jane Doe", "2": "Smith" },
3 | "age": { "0": 30, "1": 28, "2": 40 },
4 | "id": { "0": "111", "1": "222", "2": "333"}
5 | }
--------------------------------------------------------------------------------
/json-to-yaml/sample.yaml:
--------------------------------------------------------------------------------
1 | age:
2 | '0': 30
3 | '1': 28
4 | '2': 40
5 | id:
6 | '0': '111'
7 | '1': '222'
8 | '2': '333'
9 | name:
10 | '0': John Doe
11 | '1': Jane Doe
12 | '2': Smith
13 |
--------------------------------------------------------------------------------
/pdf-to-docx/requirements.txt:
--------------------------------------------------------------------------------
1 | pdf2docx
--------------------------------------------------------------------------------
/pdf-to-docx/rickroll_4k.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mpotane/PythonScriptPH/a5cc7e696a0e5fdf0405b87cd050bc0b1045e3ce/pdf-to-docx/rickroll_4k.docx
--------------------------------------------------------------------------------
/pdf-to-docx/rickroll_4k.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mpotane/PythonScriptPH/a5cc7e696a0e5fdf0405b87cd050bc0b1045e3ce/pdf-to-docx/rickroll_4k.pdf
--------------------------------------------------------------------------------
/pdf-to-docx/script.py:
--------------------------------------------------------------------------------
1 | from pdf2docx import Converter
2 |
3 |
4 | def main():
5 | pdf_file = 'rickroll_4k.pdf'
6 | docx_file = 'rickroll_4k.docx'
7 | cv = Converter(pdf_file)
8 | cv.convert(docx_file)
9 | cv.close()
10 |
11 |
12 | if __name__ == '__main__':
13 | main()
14 |
--------------------------------------------------------------------------------
/philippine-flag/phflag.py:
--------------------------------------------------------------------------------
1 | from turtle import *
2 |
3 |
4 | def blue(flag):
5 | flag.penup()
6 | flag.goto(-400, 0)
7 | flag.pendown()
8 |
9 | # Blue rectangle
10 | flag.color('blue')
11 | flag.begin_fill()
12 | flag.forward(800)
13 | flag.left(90)
14 | flag.forward(250)
15 | flag.left(90)
16 | flag.forward(800)
17 | flag.end_fill()
18 |
19 |
20 | def red(flag):
21 | flag.penup()
22 | flag.goto(-400, -250)
23 | flag.pendown()
24 |
25 | # Red rectangle
26 | flag.color('firebrick')
27 | flag.begin_fill()
28 | flag.forward(800)
29 | flag.left(90)
30 | flag.forward(250)
31 | flag.left(90)
32 | flag.forward(800)
33 | flag.end_fill()
34 |
35 |
36 | def white(flag):
37 | flag.penup()
38 | flag.goto(-400, 250)
39 | flag.pendown()
40 |
41 | # Triangle
42 | flag.color('white')
43 | flag.begin_fill()
44 | flag.forward(500)
45 | flag.left(130)
46 | flag.forward(390)
47 | flag.end_fill()
48 |
49 |
50 | def star(flag):
51 | flag.color('yellow')
52 | flag.left(36)
53 | flag.begin_fill()
54 | for _ in range(5):
55 | flag.forward(30)
56 | flag.left(144)
57 | flag.end_fill()
58 |
59 |
60 | def sun(flag):
61 | flag.penup()
62 | flag.goto(-290, -50)
63 | flag.pendown()
64 |
65 | # Drawing the sun
66 | flag.color('orange', 'yellow')
67 | flag.pensize(5)
68 | flag.begin_fill()
69 | flag.circle(50)
70 | flag.end_fill()
71 | # Drawing rays
72 | for _ in range(8):
73 | flag.rt(92)
74 | flag.fd(40)
75 | flag.bk(40)
76 | flag.lt(92)
77 | flag.circle(50, 45)
78 |
79 |
80 | def main():
81 | flag = Turtle()
82 | s = Screen()
83 | s.title('Welcome to Python PH!')
84 | flag.speed(0)
85 | s.setup(800, 500)
86 | blue(flag)
87 | flag.left(180)
88 | red(flag)
89 | flag.left(90)
90 | white(flag)
91 | flag.penup()
92 | flag.goto(-375, 185)
93 | flag.pendown()
94 | star(flag)
95 | flag.penup()
96 | flag.goto(-368, -210)
97 | flag.pendown()
98 | star(flag)
99 | flag.penup()
100 | flag.goto(-120, 0)
101 | flag.pendown()
102 | star(flag)
103 | flag.left(214)
104 | sun(flag)
105 | flag.hideturtle()
106 | done()
107 |
108 |
109 | if __name__ == '__main__':
110 | main()
--------------------------------------------------------------------------------
/proof-reader/requirements.txt:
--------------------------------------------------------------------------------
1 | lmproof
--------------------------------------------------------------------------------
/proof-reader/script.py:
--------------------------------------------------------------------------------
1 | import lmproof
2 |
3 |
4 | def proofread(text):
5 | proofread = lmproof.load("en")
6 | correction = proofread.proofread(text)
7 | print("Original: {}".format(text))
8 | print("Correction: {}".format(correction))
9 |
10 | proofread("Your Text")
--------------------------------------------------------------------------------
/qrcode/qr.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mpotane/PythonScriptPH/a5cc7e696a0e5fdf0405b87cd050bc0b1045e3ce/qrcode/qr.png
--------------------------------------------------------------------------------
/qrcode/qr.py:
--------------------------------------------------------------------------------
1 | import qrcode
2 |
3 |
4 | def main():
5 | # You can put website link here <-.
6 | img = qrcode.make('https://cdn.vox-cdn.com/thumbor/WR9hE8wvdM4hfHysXitls9_bCZI=/0x0:1192x795/1400x1400/filters:focal(596x398:597x399)/cdn.vox-cdn.com/uploads/chorus_asset/file/22312759/rickroll_4k.jpg')
7 | img.save("qr.png")
8 |
9 |
10 | if __name__ == '__main__':
11 | main()
12 |
--------------------------------------------------------------------------------
/qrcode/requirements.txt:
--------------------------------------------------------------------------------
1 | qrcode[pil]
--------------------------------------------------------------------------------
/remove-background-image/owl.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mpotane/PythonScriptPH/a5cc7e696a0e5fdf0405b87cd050bc0b1045e3ce/remove-background-image/owl.jpg
--------------------------------------------------------------------------------
/remove-background-image/owl.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mpotane/PythonScriptPH/a5cc7e696a0e5fdf0405b87cd050bc0b1045e3ce/remove-background-image/owl.png
--------------------------------------------------------------------------------
/remove-background-image/remove.py:
--------------------------------------------------------------------------------
1 | from rembg import remove
2 | from PIL import Image
3 |
4 |
5 | def main():
6 | """
7 | It takes an image and returns a new image with the background removed
8 | """
9 | img = Image.open('owl.jpg')
10 | out = remove(img)
11 | out.save('owl.png')
12 |
13 |
14 | if __name__ == '__main__':
15 | # For more info visit https://github.com/danielgatis/rembg
16 | # you need to download the model first https://github.com/danielgatis/rembg#models
17 | main()
18 |
--------------------------------------------------------------------------------
/remove-background-image/requirements.txt:
--------------------------------------------------------------------------------
1 | rembg
--------------------------------------------------------------------------------
/soundrecorder/script.py:
--------------------------------------------------------------------------------
1 | import sounddevice
2 | from scipy.io.wavfile import write
3 |
4 |
5 | def main():
6 | fs = 44100 # Sample rate
7 | seconds = 10 # Duration of recording
8 |
9 | myrecording = sounddevice.rec(int(seconds * fs), samplerate=fs, channels=2)
10 | sounddevice.wait() # Wait until recording is finished
11 | write("output.wav", fs, myrecording) # Save as WAV file
12 |
13 | if __name__ == "__main__":
14 | main()
--------------------------------------------------------------------------------
/speed-test/requirements.txt:
--------------------------------------------------------------------------------
1 | speedtest
2 |
--------------------------------------------------------------------------------
/speed-test/speedtest.py:
--------------------------------------------------------------------------------
1 | import speedtest
2 |
3 |
4 | def main():
5 | try:
6 | st = speedtest.Speedtest()
7 | server_names = []
8 | st.get_servers(server_names)
9 | downlink_bps = st.download()
10 | uplink_bps = st.upload()
11 | ping = st.results.ping
12 | up_mbps = round(uplink_bps/1000000,2)
13 | down_mbps = round(downlink_bps/1000000,2)
14 | print('speed test results:')
15 | print('ping: {} ms'.format(ping))
16 | print('upling: {} Mbps'.format(up_mbps))
17 | print('downling: {} Mbps'.format(down_mbps))
18 | except:
19 | print("Speed test can't perform right now!")
20 |
21 |
22 | if __name__ == '__main__':
23 | main()
24 |
--------------------------------------------------------------------------------
/text-to-tagalog/code.py:
--------------------------------------------------------------------------------
1 | from gtts import gTTS
2 | # if you use GNU/Linux you might have to install pygobject for playsound to work.
3 | from playsound import playsound
4 |
5 |
6 | def main():
7 | # Tagalog = 'tl' btw
8 | sp = gTTS(text='Kumusta yung mundo mo', lang='tl', slow=False)
9 | sp.save('tunog.mp3')
10 | playsound('tunog.mp3')
11 |
12 |
13 | if __name__ == '__main__':
14 | main()
15 |
--------------------------------------------------------------------------------
/text-to-tagalog/requirements.txt:
--------------------------------------------------------------------------------
1 | gtts
2 | playsound==1.2.2
--------------------------------------------------------------------------------
/text-to-tagalog/tunog.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mpotane/PythonScriptPH/a5cc7e696a0e5fdf0405b87cd050bc0b1045e3ce/text-to-tagalog/tunog.mp3
--------------------------------------------------------------------------------
/usd-to-peso/convert.py:
--------------------------------------------------------------------------------
1 | from forex_python.converter import CurrencyRates
2 |
3 |
4 | def main():
5 | # The code below is for converting the amount in USD to PHP.
6 | rate = CurrencyRates()
7 |
8 | amount = float(input("Enter amount in USD: "))
9 |
10 | differential = rate.convert('USD', 'PHP', amount)
11 |
12 | print(f'₱ {differential:,.2f}')
13 |
14 |
15 | if __name__ == '__main__':
16 | main()
17 |
--------------------------------------------------------------------------------
/usd-to-peso/requirements.txt:
--------------------------------------------------------------------------------
1 | forex_python
--------------------------------------------------------------------------------
/youtube-video-downloader/README.md:
--------------------------------------------------------------------------------
1 | The code will help to download a video from youtube.
2 |
3 | ## Installation
4 |
5 | - Install Python to your system.
6 |
7 | - Install the module **pytube**
8 |
9 | - Do it by typing this on Power Shell (for Windows) or Bash (for Linux)
10 |
11 | ```bash
12 | python3 -m pip install pytube
13 | ```
14 |
15 | Once **pytube** is installed, you can use the script to download a video.
16 |
--------------------------------------------------------------------------------
/youtube-video-downloader/download_video.py:
--------------------------------------------------------------------------------
1 | from pytube import YouTube
2 |
3 |
4 | """
5 | `yt = Youtube('https://www.youtube.com/watch?v=dQw4w9WgXcQ')`
6 |
7 | This line of code creates a variable called `yt` and assigns it the value of the `Youtube` class.
8 | The `Youtube` class is a class that is defined in the `pytube` library. The `Youtube` class takes in
9 | a single argument, which is the URL of the YouTube video that you want to download.
10 |
11 | `yt.streams.get_by_itag(18).download()`
12 |
13 | This line of code calls the `download` method on the `yt` variable. The `download` method is a
14 | method that is defined in the `Stream` class, which is a class that is defined in the `pytube`
15 | library. The `download` method takes in no arguments.
16 |
17 | The `yt` variable is an instance of
18 | """
19 | def main():
20 | yt = YouTube('https://www.youtube.com/watch?v=dQw4w9WgXcQ')
21 | yt.streams.get_by_itag(18).download()
22 |
23 |
24 | if __name__ == '__main__':
25 | main()
26 |
--------------------------------------------------------------------------------
/youtube-video-downloader/requirements.txt:
--------------------------------------------------------------------------------
1 | pytube
2 |
--------------------------------------------------------------------------------