What Are Some Useful Python Scripts - Quora
What Are Some Useful Python Scripts - Quora
com/What-are-some-useful-Python-scripts
Python Scripts Scripting (programming) Learning Python Python (programming language) Related Questions
Umang Ahuja, Switch to python if you want fun What can be done with Python?
Answered Jul 24, 2017 · Author has 643 answers and 683.5k answer views
What is Python programming language NOT used
I have recently started writing blog on Quora to share my scripts with fellow Quorans so for?
that we learn together and improve.
What is the importance of the Python language?
Here is the link : Get Set Python
What are the benefits of Python?
The reason for uploading these is that there is no proper resource for scripting which a
newcomer can follow that makes him feel like “Yeah Python is awesome”.
I have written many scripting meanwhile learning Python Scripting which eases the
cumbersome tasks and can prove beneficial for lazy people like me.
—————————————————————————————————————
This is a very beginner friendly script that uses just time module to record start and end time.
So if anyone who want to start scripting, this is just perfect piece of code to get started.
Code:
1 of 17 5/6/2020, 11:26 PM
What are some useful Python scripts? - Quora https://www.quora.com/What-are-some-useful-Python-scripts
20 t = input()
21 end = time()
22 if t == s:
23 total = round(end - start, 2)
24 print("\nVoila you typed that correctly")
25 print("Your time was %s seconds" % total)
26 total = int(total) / 60 print("Speed was %s wpm" % (str(words
27
28 else:
29 print("\nWrongly entered")
30 print("Try again")
31
32 except KeyboardInterrupt:
33 print("")
What are the things that I need to learn in Python to be able to write scripts for
downloading stuff?
Is there a way to call a program in Python and not wait for it to end (Python)?
Anonymous
Answered Mar 10, 2018
Some might say it is funny or cool, but I would call it one of the most helpful and
interesting scripts I have ever written.
First, I will have to give you some context here. I come from India, and some people here
take it upon themselves to decide what other people should do with their life all in the
name of ”preserving the culture”. So, a few things which are more often taken for granted
in western countries, have a great deal of stigma attached to it here.
One such thing is getting pregnant as an unmarried couple. If at all this happens to you,
may the force be with you! Society will shun you and your partner, and look at you as if
you do not deserve to roam this planet alive. To make this worse, even your parents will
treat you the same as if you have done something that will bring an apocalypse to our
world. They won't care about you or your baby, all they will care about is 'log kya
kahenge?' (what will people say?). Obviously, the couple often tries to find out a way to
discreetly get out of the situation, unless of course, they are ready to fight the society and
keep their "illicit" (sarcasm, just in case people fail to understand. It happens more often
than you think it happens.) baby.
So, one day I was minding my business and eating a burger, my friend calls me and says,
"Bro, I am screwed! I got my girl pregnant!". First, my body goes numb, the second panic
attack starts to set in. There was a pin-drop silence for over a minute on both sides. My
brain had imagined all the probable sh#t that was about to go down in that minute.
Somehow, I calmed myself and asked him to remain calm. I advised him to visit a
gynecologist, the same day. So, he goes to a local gynecologist with his girlfriend, and
here's how it goes down.
Although it is legal to get an abortion in India up to 20 weeks of getting pregnant for both
married and unmarried lady, above mentioned people, "to preserve the culture" choose to
neglect the unmarried ones. Unfortunately, that local gynec was amongst such people.
First, she took all their details, name, phone number address etc, and then slammed them
for being unmarried. She said she does not entertain unmarried couples and shooed them
2 of 17 5/6/2020, 11:26 PM
What are some useful Python scripts? - Quora https://www.quora.com/What-are-some-useful-Python-scripts
It was then understood that visiting random gynecs won't cut it out. So, there is this
startup in India which help people, search doctors according to the services they provide
and book an appointment, all from their website/app. So we searched and found hundreds
of doctors in the area who specialized in MTP. We decided to go check the reviews of
doctors and see if anyone in our situation had opted for MTP and got a positive result.
However, the list of doctors was large and many doctors had thousands of reviews and the
review page showed only a few reviews at a time. It was impossible to go through every
review manually. That is when I had an idea.
I pulled out my laptop and started writing a python web crawler. I somehow managed to
write the script in few hours. The crawler searched the website for the doctors who are
specialized in MTP, in a given list of localities. Then, it hit the patient review API for each
doctor listed in the list and run it in a loop until all reviews were extracted. Then I placed a
keyword filter on the reviews, like 'MTP', 'unmarried', 'scared', etc and the crawler
generated a systematic report for each doctor in an individual file, listing their name,
address, experience, contact, fees and the filtered reviews.
This helped us close in on a perfect doctor and my friend's case was discreetly closed
without any complications. This is the most interesting piece of script I have ever written.
16.7k views · View 24 Upvoters
I am a beginner in Python programming and don’t have much experience with Python. So i
write very small scripts to automate tedious tasks.
Whenever i download a video from Youtube through IDM it is saved with a prefix like (12),
(13),(21) [filename] … etc and all i have to do is rename all files manually.
1 import os
2 for filename in os.listdir("."): #for current directory
3 if filename.startswith("("):
4 os.rename(filename, filename[5:])
Now after downloading videos i execute this script in download directory and all files
renamed automatically.
1. I am fond of cool Desktop wallpapers and usually download them from various
websites.
2. One day i was sorting them according to their resolution e.g 4K, 1080p, 720p etc.
3 of 17 5/6/2020, 11:26 PM
What are some useful Python scripts? - Quora https://www.quora.com/What-are-some-useful-Python-scripts
Now all i have to do is just relax and sit back with my coffee cup and my script will create
different directories and move wallpapers to them.
4 of 17 5/6/2020, 11:26 PM
What are some useful Python scripts? - Quora https://www.quora.com/What-are-some-useful-Python-scripts
Note: I know that this is not a cool scripts they saves me a lot amount of time and i hope
yours will too.
Happy Coding :)
1. Facebook chat bot :- A bot which says a random Chuck Norris joke to every message in
facebook. I have blogged about it here Achin Sagar's post in Coding experiments .
2.Car racing game control using opencv with python:- Control car on track by detecting
a colored object which is in my case a blue to bottle cap. I have blogged about it here
Achin Sagar's post in Coding experiments .
5 of 17 5/6/2020, 11:26 PM
What are some useful Python scripts? - Quora https://www.quora.com/What-are-some-useful-Python-scripts
3.Play songs or videos from command line from a search query :- This script takes
input from the command line and based on the input it plays a random song or video ,
play a song or video by its name ( The cool thing is the name need not match exactly , a
small algorithm is run to check for similarity between names and plays the best match). I
have blogged it here Achin Sagar's post in Coding experiments .
4.Open firefox , login to fb/twitter and post a status automatically:- I pass my userid
and password to the script and it logs into my account and posts a status automatically. I
have blogged it here Achin Sagar's post in Coding experiments .
5.Script to scrape flipkart to get reviews of a product:- The script makes a request to
flipkart with a search query and scrapes the review data to a list. I have blogged it here
Achin Sagar's post in Coding experiments .
How do I write a python script to check my exam results when uploaded and notify me?
6 of 17 5/6/2020, 11:26 PM
What are some useful Python scripts? - Quora https://www.quora.com/What-are-some-useful-Python-scripts
Edit: In the end, I have included a video where I parse last 3 contests of Ashish Gupta a.k.a
Ashishgup.
For a guy like me who likes to keep all my codeforces submissions organised , this script
saves a lot of unnecessary time in organising codes in folders .At last, I can push all my
codes to Github in ...
Dinesh Makkar
Updated Jun 29, 2017
1. I wrote a small python script which helps in increasing my vocabulary. What this
does is, (most of the time I am in terminal in ubuntu) every time I launch a new
terminal, it picks a random word from a dictionary and searches its meaning on
web and displays 2 or 3 definitions of it and synonyms also if available. In
beginning script has small local dictionary from which it randomly selects words.
You can also search a word on your own. (I made an alias “dict” to that python
script so that I don’t have to type whole long path to python script to get the
meaning. ). So I can use directly “user@host$ dict WORD”. As I search a new word
that is not in the local dictionary, script automatically adds this word to local
dictionary so that next time when script randomly picks a word, new word just
now added might also get selected.
2. Similar to previous one, I wrote another python script to display a quote from
local collection of quotes. It randomly selects type of quote (success , educational,
motivational. inspirational and 1 more) and then random selects 1 out of those
approx. 100 quotes of the selected type and displays it on the terminal as I launch
a new terminal. (I again made an alias “quo” to this python script ) which does the
same work. Just type “quo” in the terminal and it shows a quote to make your
day.
Talking about personal experience, I always say to myself that I will read some
new at least 10 words from dictionary or some other source but I have never been
able to learn even 10 words per day. But this script does my work no matter what.
Thanks.
23k views · View 50 Upvoters
N.B
7 of 17 5/6/2020, 11:26 PM
What are some useful Python scripts? - Quora https://www.quora.com/What-are-some-useful-Python-scripts
library to scrape the data from Real Madrid's official website and made a simple
countdown. In a few days I used Python and Flask to make a good looking website that
does the same function. See it here : http://madrid-kickoff.herokuapp.com
This one I made yesterday and could be useful to you if you love changing and putting on
cool desktop wallpapers like me.
I used to search google images -> search for high resolution image -> download and set
as wallpaper. I automated that yesterday.
Moreover, I ported script to alternative version where you could download all the 100
photos for given search term at once. Cool, right?
Sounds interesting enough for you? Check out the script here → amit-bhandari/quick-
wallpaper-changer-linux and if someone can, please help porting the script for
Windows as I don’t know how to change wallpaper from cmd in windows.
8 of 17 5/6/2020, 11:26 PM
What are some useful Python scripts? - Quora https://www.quora.com/What-are-some-useful-Python-scripts
‘Aston Martin’
‘Lamborghini’
Let me know in comments what do you guys think about this. Peace out.
Do star and fork it on Github to let more people know about this useful script
Give my android app thumbs up AB Music - Lightweight music player with Lyrics HD -
Android Apps on Google Play on Google play. I am sure you are going to love it.
Edit 2: I have written about cool computer tricks here Amit Bhandari's answer to What are
some good computer tricks that are not commonly known?, check that out as well, they
will be helpful for sure.
9 of 17 5/6/2020, 11:26 PM
What are some useful Python scripts? - Quora https://www.quora.com/What-are-some-useful-Python-scripts
Quora User
Answered Jun 7, 2017 · Upvoted by Ashutoh Purohit, C.Sc Computer Programming & Tavelling,
SRM University, Modinagar (2019)
Couple of days back I was watching Ind vs Pak (ICC Champions Trophy, 2017 ) which was
interrupted due to rain. I came home early from my college just to see the match. As soon
as I entered my room, rain god decided to obstruct the much anticipated match. After
waiting for the game to resume, I decided to write my own script that fetches commentary
from CricBuzz and reads it. Whenever I am away from my TV i run this script in background
(Source : Google)
When you are serious about the programming language, you have studied the basics.
Some include easy data structures, sufficient algorithms, control flow and looping, data
types, function declaration, class programming, and useful operators. You should just
"know" these elements of the language, and apply them unconsciously. A proficient
enough level in basic programming logically follows to smart use of libraries. Programmers
more experienced than you have developed optimal data structures and algorithms, and
classes for particular use cases. You just need to understand them enough to apply them
correctly. You get bonus points if you know the design and can implement their optimal
solutions.
3.2k views · Answer requested by Pio Leo
I was new to ubuntu and used to spend most of the time on terminal(practicing
commands) at the same time I was eager to read tech and sports news. but opening and
browsing through websites was killing my time and I could not spending much time
practicing commands.
while thinking about a solution, I came to know about this NEWS API service which
provides simple and easy-to-use API that returns JSON metadata for the headlines currently
published on a range of news sources and blogs.
1 #!/usr/bin/python3
2 import json as js
3 import urllib.request
10 of 17 5/6/2020, 11:26 PM
What are some useful Python scripts? - Quora https://www.quora.com/What-are-some-useful-Python-scripts
6 url=' https://newsapi.org/v1/articles?'+'source='+source+'&sortBy='
7 # print(url)
8 data=urllib.request.urlopen(url).read().decode('utf-8')
9 newsdata = js.loads(data)
10 return newsdata
11
12 def grabSources(language):
13 url=' https://newsapi.org/v1/sources?language='+language
14 rawSource=urllib.request.urlopen(url).read().decode('utf-8')
15 allsources=js.loads(rawSource)
16 sourcesEnlist = [x['id'] for x in allsources['sources']]
17 return sourcesEnlist
18
19 while choice !='0':
20 sources=grabSources('en')
21 print('select a news source you like[using number]')
22 for sno,item in enumerate(sources):
23 print(sno,'->',item)
24 sltsource=int(input('enter your choice:'))
25 newsdata=grabNews(sources[sltsource],'top','PASTE YOUR API KEY HERE')
26 print('--------------------------------------------------------------------------------
27 for news in newsdata['articles']:
28 print(str(news['title']).upper())
29 print(news['description'])
30 print('url-> ',news['url'])
31 print('-----------------------------------------------------------------------------
32 print(' ')
33 choice=str(input('enter "0" to leave news'))
2. open terminal at the same directory where you saved this script and run these
commands one by one
1 chmod -x news.py
2 sudo cp news.py /usr/local/bin/news
3 sudo chmod a+x /usr/local/bin/news
that’s it.
now just type news on your terminal whenever you feel to read news
now you will get description and link of top news from that website
11 of 17 5/6/2020, 11:26 PM
What are some useful Python scripts? - Quora https://www.quora.com/What-are-some-useful-Python-scripts
footnotes: I know that this isn’t a wise code but this saves me a heck amount of time and i
hope yours will too.
:)
13.5k views · View 32 Upvoters
And repeating these same steps for every project is boring, so I made a Python and a shell
script that would do all these steps with only one command.
1 import sys
2 import os
3 from github import Github
4
5 path = "/path/to/your/desired/projects/directory"
6
Continue Reading
I have written few scripts which can help one explore the capabilities of Python.
1 import moviepy.editor as mp
2 video = mp.VideoFileClip("SampleVideo.mp4")
3 video.audio.write_audiofile("SampleAudio.mp3")
This script fetches all the mobile network plans of all the operators in all the states in India.
You can compare rates offered by operators across different states from one single csv file.
Continue Reading
12 of 17 5/6/2020, 11:26 PM
What are some useful Python scripts? - Quora https://www.quora.com/What-are-some-useful-Python-scripts
Bookmarked Answers is place where we find some of the most interesting answers we
liked on Quora.
Here is a Python script to download all your bookmarked answers in pdf to read them
whenever you like.
Continue Reading
Edwin Lazar
Answered Mar 9, 2017 · Author has 85 answers and 302k answer views
Hi,
08_basic_email_web_c
Continue Reading
Continue Reading
13 of 17 5/6/2020, 11:26 PM
What are some useful Python scripts? - Quora https://www.quora.com/What-are-some-useful-Python-scripts
15 with open(fname,'wb') as f:
16 f.write(data)
17 except IOError as e:
18 if e.errno != 2:
19 raise e...
===========================================
password = raw_input('Enter the password ')
special = '!@#$%^&*()
if len(password) >= 8 a
password.isalpha() and
Continue Reading
Although I am a beginner myself and don’t have much experience with Python, but I’ve
started writing Python scripts and I feel that it’s a great way to learn Python along with
automating tedious tasks. The scripts that I’ve written may not be of that much common
use but they anyway gave me a good start in learning Python.
1. A Python script to set a network usage limit and get notified when the
network usage exceeds that limit
Github link: https://github.com/adityashrm21/...
1 #!/usr/bin/env python
2 import os
3 import sys
4 import time
Continue Reading
The anaconda installer in Fedora is also a Python script and so is a large number of
administrative utilities.
6.2k views · View 5 Upvoters
Continue only
The couple of online websites I used allowed Reading
2 edits/hour and the other option was to
14 of 17 5/6/2020, 11:26 PM
What are some useful Python scripts? - Quora https://www.quora.com/What-are-some-useful-Python-scripts
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 """
4 This script is used to split/merge multiple pdf files.
5 python pdf_worker.py -f http://filename1.py -p 1-5 -f http://filename2.py -p 4,5,7 -f htt
6 Files ar...
I have learnt many things with python! It is like a superpower when you know to code.
Specially in Python!
Features -
Simple conversations.
Speech Recognition.
Text-To-Speech.
Playing music.
Sending emails.
2. I have also written a second version of it with some GUI and named it KAREN.
Check it out -
15 of 17 5/6/2020, 11:26 PM
What are some useful Python scripts? - Quora https://www.quora.com/What-are-some-useful-Python-scripts
Webpage2Kindle
I recently wrote a simple yet useful script for sending Webpages directly to one’s kindle
using a Single Command:
Send the generated .pdf file to the kindle email associated with your kindle via
your gmail account which is added as trusted device in your amazon kindle
settings, via a smtp gmail server
So, this one's a very basic and an easy one. I had a folder in my system in which files of
multiple types were there (.txt , .mp3). That was much of a mess and thus I decided to
organize them in a way that images are in one folder and songs in one. I started moving
them but I had so many songs and images, moving them individually was a very tedious
job. There it struck me writing this python script which can automatically create a separate
directory/folder and mo
Couple of days back I was watching Ind vs Pak (ICC Champions Trophy, 2017 ) which was
interrupted due to rain. I came home early from my college just to see the match. As soon
as I entered my room, r
waiting for the game to
from CricBuzz and read
Continue Reading
16 of 17 5/6/2020, 11:26 PM
What are some useful Python scripts? - Quora https://www.quora.com/What-are-some-useful-Python-scripts
(Source : Google)
To add more fun, i recorded Danny Morisson’s and Harsh Bhogle’s boundary,six and wic...
Related Questions
What are the things that I need to learn in Python to be able to write scripts for
downloading stuff?
Is there a way to call a program in Python and not wait for it to end (Python)?
What are some cool python scripts [Windows/Linux] to minimise daily tasks?
17 of 17 5/6/2020, 11:26 PM