Skip to main content

Posts

Showing posts from June, 2020

5 Unique and Useful Python modules.

Motive           There are different types of modules in python which not everyone knows so we thought of introducing them to you guys. Let's start! Note: This is not a tutorial of how to use these but is to show that these modules also exist and if you want to know more you can visit there own page and if you want us to explain leave a comment below. Links to there page are also given below. Hope you found something useful. 1.Wikipedia          Yes, there is a module called Wikipedia in python, you can easily install Wikipedia by pip install wikipedia . We cannot rely on this module for advanced use. It was designed for ease of use and simplicity.  Learn More Here .  Here is a simple example: import wikipedia wikiPython = wikipedia.summary("Python", sentences=2) print(wikiPython)           One big disadvantage is that it works only if the interne...

Shutdown Computer with Python | Shutdown Prank .

Motive          Pranking friends is really fun. So, I thought of sharing an idea for pranking your friends with python. Or if you have any problem with your power button you could use it. The Project          It's really very simple no pip installs and just two lines of code and we are done. First let's import a module called os, again no need for any pip it's pre-installed in python. Import the module and give the command for shutdown: import os os.system('shutdown /s /t 0')           Here shutdown is the command for shutdown we can even use sleep or restart,  /s tells  that the shutdown should happen in that PC and /t tells about the time and 0 is the seconds that are left for the shutdown to happen it can be from 0 to 315360000 i.e 5 years.           But even a person who knows to read English can understand the code so we have to hide it somewhere either in c...

Find MAC Address with Python

Motive          This is just as a fun project which you can even use for other backend projects, who don't like python and programing with it so let's dive through the modules in python. The Project          Let's start by importing the module which is pre-installed, UUID. You can learn more  here . Now, let's import the module:  import uuid           Now let's create a variable called mac and then get the MAC address and then format it into a string from a 48-bit number and the add a ':', colon after two digits: mac = ':'.join(['{:02x}'.format((uuid.getnode()>>x) & 0xff) for x in range (0,8*6,8)][::-1]) Now let's print the MAC address after converting it with uppercase letters: print('MAC Address:',mac.upper()) So that's it we have got our MAC address with just 4 lines of code. Full Code import uuid mac = ':'.join(['{:02x}'.format((uuid.getnode()>>x) & 0xff) ...

Python QR Code Decoder | QR Code to text

Motive           In our last blog, we created a QR code generated with python so why not a decoder to decode the QRcode without scanning it.  Project             Before starting to make a project lets install the necessary modules for this project,  pyxbar  and  pillow . Motive           In our last blog, we created a QR code generated with python so why not a decoder to decode the QRcode without scanning it.  Project             Before starting to make a project lets install the necessary modules for this project,  pyxbar  and  pillow . pip install pyzbar pip install pillow           Open your cmd and type those codes separately to install  pyzbar  and  pillow and you can learn more about  pyzbar  here ...

Python QR Code Generator

Motive          QR Codes are seen everywhere, even tho it's not really useful we could encrypt some data in them or we could even use it for other backend purposes. Let's begin! Project          Before starting to make a project lets install the necessary modules for this project, pyqrcode and pypng . Even tho we are not importing pypng directly the module pyqrcode imports it and if we try running without installing pypng we will get an error so install both of them. pip install pyqrcode pip install pypng     Open your cmd and type those codes separately to install pyqrcode and pypng and you can learn more about pyqrcode  here and pypng  here . Let's start by importing the necessary modules for our project: import os,pyqrcode      It's not necessary to import os. But if you want to open the QR code after it's created by the pro...

Python | if __name__ == '__main__' Explained | Python Tutorial

Motive          When I was a beginner I had this big doubt while watching tutorials on YouTube. I saw people using this  if  __name__ ==  '__main__'  even though it was not required. So, I thought of learning the special variables in python. So I thought that this will be useful for you guys also. Let's Learn          First I created a folder named special variables and then created a new python file called mainProgram and tried printing  __name__ in this file like this: print(__name__)  I got the result as  __main__ in the python shell. Then I tried printing its type like so: print(type(__name__))           Now I got  <class 'str'>  in the python shell. So that's why we use inverted commas for __main__ ( since it is a string).         Now let's create a new python file called importedProgram, in the same folder and import t...

Face Detection with Open CV | Unsupervised learning in Python

Motive                  Machine Learning is not that easy to lean in python and YouTube tutorials cannot rely heavily so I taught of making a model and explain to you guys how machine learning works. We will not be making the rules for the model instead we will take a pre-trained model for our use. Training a model takes time and we need a lot of data so we will take the easier path for now.  The Project          The only library that we need is OpenCV, if you have not installed it then pip install it in your terminal,  pip install opencv-python .  You can learn more  here . Now open your preferred ide and import opencv, while coding we use cv2 for opencv: # import opencv import cv2           Now as I told above we will use a pre-trained model for this use so download it from  here . Now let's mention it in the code and ensure that the XML file is in th...